VB.NET:
[COLOR="Blue"]Public Const[/COLOR] LOCALE_SABBREVCTRYNAME& = &H7 [COLOR="SeaGreen"]' abbreviated country name[/COLOR]
[COLOR="#0000ff"]Public Const[/COLOR] LOCALE_SENGCOUNTRY& = &H1002 [COLOR="#2e8b57"]' English name of country[/COLOR]
[COLOR="Blue"]Public Const[/COLOR] LOCALE_SYSTEM_DEFAULT& = &H400
[COLOR="#0000ff"]Public Const[/COLOR] LOCALE_USER_DEFAULT& = &H800
[COLOR="#0000ff"]Public Const[/COLOR] LOCALE_NOUSEROVERRIDE& = &H80000000
[COLOR="#0000ff"]Declare Auto Function[/COLOR] GetLocaleInfo [COLOR="#0000ff"]Lib[/COLOR] "kernel32" [COLOR="#0000ff"]Alias[/COLOR] "GetLocaleInfoA" ([COLOR="#0000ff"]ByVal[/COLOR] Locale [COLOR="#0000ff"]As Integer[/COLOR], [COLOR="Blue"]ByVal[/COLOR] LCType [COLOR="#0000ff"]As Integer[/COLOR], [COLOR="#0000ff"]ByVal[/COLOR] lpLCData [COLOR="#0000ff"]As String[/COLOR], [COLOR="#0000ff"]ByVal[/COLOR] cchData [COLOR="#0000ff"]As Integer[/COLOR]) [COLOR="#0000ff"]As Integer[/COLOR]
[COLOR="Blue"]Public Declare Auto Function[/COLOR] GetUserDefaultLangID [COLOR="#0000ff"]Lib[/COLOR] "kernel32" [COLOR="#0000ff"]Alias[/COLOR] "GetSystemDefaultLangID" () [COLOR="#0000ff"]As Integer[/COLOR]
[COLOR="#0000ff"]Public Declare Auto Function[/COLOR] GetUserDefaultLCID [COLOR="#0000ff"]Lib[/COLOR] "kernel32" [COLOR="#0000ff"]Alias[/COLOR] "GetUserDefaultLCID" () [COLOR="#0000ff"]As Long[/COLOR]
[COLOR="#0000ff"]Public Shared Function[/COLOR] GetUserLocaleInfoEx([COLOR="#0000ff"]ByVal[/COLOR] dwLocaleID [COLOR="#0000ff"]As Integer[/COLOR], [COLOR="#0000ff"]ByVal[/COLOR] dwLCType [COLOR="#0000ff"]As Integer[/COLOR]) [COLOR="#0000ff"]As String[/COLOR]
[COLOR="#0000ff"]Dim[/COLOR] sReturn [COLOR="#0000ff"]As String[/COLOR]
[COLOR="#0000ff"]Dim[/COLOR] r [COLOR="#0000ff"]As integer[/COLOR]
[COLOR="SeaGreen"] 'call the function passing the Locale type
'variable to retrieve the required size of
'the string buffer needed[/COLOR]
r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
[COLOR="SeaGreen"] 'if successful..[/COLOR]
[COLOR="#0000ff"]If[/COLOR] r [COLOR="#0000ff"]Then[/COLOR]
[COLOR="#2e8b57"] 'pad the buffer with spaces[/COLOR]
sReturn = Space$(r)
[COLOR="#2e8b57"] 'and call again passing the buffer[/COLOR]
r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
[COLOR="#2e8b57"] 'if successful (r > 0)[/COLOR]
[COLOR="#0000ff"]If[/COLOR] r [COLOR="#0000ff"]Then[/COLOR]
[COLOR="#2e8b57"] 'r holds the size of the string
'including the terminating null
'GetUserLocaleInfoEx = sReturn.Substring(0, r - 1)[/COLOR]
GetUserLocaleInfoEx = Microsoft.VisualBasic.Strings.Left(sReturn, r - 1)
[COLOR="#0000ff"]End If[/COLOR]
[COLOR="#0000ff"]End If[/COLOR]
[COLOR="#0000ff"]End Function[/COLOR]
VB.NET:
[COLOR="Blue"]Private Sub[/COLOR] Form1_Load([COLOR="#0000ff"]ByVal[/COLOR] sender [COLOR="#0000ff"]As[/COLOR] System.Object, [COLOR="#0000ff"]ByVal[/COLOR] e [COLOR="#0000ff"]As[/COLOR] System.EventArgs) [COLOR="#0000ff"]Handles MyBase[/COLOR].Load
[COLOR="#0000ff"]Dim[/COLOR] Country [COLOR="#0000ff"]As String[/COLOR]
Country = GetUserLocaleInfoEx(LOCALE_USER_DEFAULT, LOCALE_SENGCOUNTRY)
MsgBox(Country)
[COLOR="#0000ff"]End Sub[/COLOR]
The msgbox shows "湕瑩摥匠慴整s "
Why isn't it returning the correct country?
(You can find a few Articles on GetLocaleInfo with google as I have, however none of them helped me solve the problem)