Sign in to follow this  

How to get Country of local machine?

This topic is 4689 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I update a highscore database on the Internet for my hame but would like to also store the Country. Is there a way in Windows to painlessly get the Country without prompting the user? I was going to use the IP address and do a Country lookup but that's a real pain... not quite as simple as I thought. Would be ideal if the function returned "us", "au","nz","ru"...etc. I'm sure storing the Country with the high scores would create a bit of inter-Country rivalry for the top 20 high scores. It would also let mess see where people using the game are from.

Share this post


Link to post
Share on other sites
This code seems to work for me:

char szBuff[32];
GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SCOUNTRY,szBuff,32);


Which gives "United Kingom" in szBuff. Using LOCALE_SYSTEM_DEFAULT gives "United States", which is wrong.
If you want that string as a 2 letter string (e.h. "uk", "us", "nz", etc), you could have some sort of mapping table to convert "United States" to "us" and so on.

Share this post


Link to post
Share on other sites

This topic is 4689 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this