Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to access a PC's location? 3

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
AU
I am using a date string in a log file which I would like to conform to the user's current location in the world.

I have a drop down on my main form with the VFP date options for the user to choose from but I would like to give them the correct start point ( BRITISH,AMERICAN etc) in case they miss changing the drop down.
Is there a way to get this info from a PC?
Many thanks

GenDev
 
Try this:

Code:
DECLARE SHORT GetSystemDefaultLangID IN kernel32
lnID = GetSystemDefaultLangID()

Then see here to interpret the value of lnID. This is the locale of the user's system (roughly equivalent to country). It is then up to you to map these to VFP date settings.

For example, if the ID is 0x0809, this specifies UK, so your default date setting would be BRITISH.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
The simplest way to let a date conform to the users system settings is SET SYSFORMATS ON.
Read about the behaviour of SET SYSFORMATS in the help. You "subscribe" to system changes with this setting, too.
Also note setting this OFF does not reset your VFP defaults, restarting VFP does.

When the DATE() isn't formatted in the way the user is used to, after you SET SYSFORMATS ON, he simply didn't make the correct OS settings and that's not your problem. Especially you can refer him to the Windows locale settings.

For Logs I personally prefer YYYYMMDD, as that also sorts chronological on it's own, even though it isn't any locales date format. Especially in file names. In log lines it's less important, they are physically sorted by the file anyway and of course files can also be sorted by their creation time anyway, but with file names in that way you can sort files by name and have sections of multiple log file types sorting chronologcally at the same time.

Bye, Olaf.
 
Thanks everyone,
I have added a checkbox to my form so that the user can either choose the current locale or change to another date format by means of the drop down ( which is disabled until the checkbox is cleared.

GenDev
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top