Sign in to follow this  
Followers 0
MadaraUchiha

Country Iso Code

5 posts in this topic

Hi,

I have a country/language problem again...

I like to grab the TwoLetterIsoCountryCode of the current computer...

I know I can grab it from the kernel32.dll - GetLocaleInfoW.

Func _WinAPI_GetLocaleInfo($LCID, $iType)
    Local $Ret = DllCall('kernel32.dll', 'int', 'GetLocaleInfoW', 'dword', $LCID, 'dword', $iType, 'wstr', '', 'int', 2048)
    If @error Or Not $Ret[0] Then Return SetError(@error + 10, @extended, '')

    Return $Ret[3]
EndFunc

Func _WinAPI_GetUserDefaultLCID()
    Local $Ret = DllCall('kernel32.dll', 'dword', 'GetUserDefaultLCID')
    If @error Then Return SetError(@error, @extended, 0)
    Return $Ret[0]
 EndFunc
 
 ConsoleWrite(_WinAPI_GetLocaleInfo(_WinAPI_GetUserDefaultLCID(),'0x59')& @LF)

This is not how I like it to go. Because, on my german PC it returns de thats fine, but on a american windows it returns en instead of us as it should.

So I think it returns the isocode for the language, not the country. (en = english) (us = united states).

I need to Iso Code from the Country, not from the language. How can I fix this?

And no, I already tried the _WinAPI_GetGeoInfo() & _WinAPI_GetUserGeoID() , same problem, so I think it can be fixed by a single DLL call? But whats the correct function to call and whats the Hex number i have to set as parameter?


Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What does 0x59 correspond to? Because I don't see that value anywhere.

EDIT: Found it, that value equals $LOCALE_SISO639LANGNAME so what did you expect to get from the function other than the language, when that's what you asked it for?

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Got it. The value needs to be 0x90.


Share this post


Link to post
Share on other sites

Use the constants, then you'll know what it is you're  passing the function. Don't use the values of the constants, use the actual variables that are set with the values. 2 weeks from now you'll look at the code and have no idea what 0x90 is supposed to do. If you had done that in the first post, you'd KNOW you're using the wrong value because the constant name tells you that it's for the language.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

> I need to Iso Code from the Country,

From which country? The country in which the computer is actually? The country where the computer was purchased? The country the computer was produced? The country in where the OS was purchased?

I think you can't get what you want... ;-)

A-Jay


Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Share this post


Link to post
Share on other sites

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  
Followers 0