INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to access a PC's location?

How to access a PC's location?

(OP)
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

RE: How to access a PC's location?

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

RE: How to access a PC's location?

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.

RE: How to access a PC's location?

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close