Option Compare Database
Option Explicit
Private Declare PtrSafe Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Private Const LOCALE_USER_DEFAULT = &H400
Private Const LOCALE_SDECIMAL As Long = &HE
Private Const LOCALE_ILDATE As Long = &H22
Private Const LOCALE_ICOUNTRY As Long = &H5
Private Const LOCALE_SENGCOUNTRY = &H1002 ' English name of country
Private Const LOCALE_SENGLANGUAGE = &H1001 ' English name of language
Private Const LOCALE_SNATIVELANGNAME = &H4 ' native name of language
Private Const LOCALE_SNATIVECTRYNAME = &H8 ' native name of country
Public Function GetInfo(ByVal lInfo As Long) As String
Dim Buffer As String
Dim Ret As String
Buffer = String$(256, 0)
Ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, Buffer, Len(Buffer))
If Ret > 0 Then
GetInfo = Left$(Buffer, Ret - 1)
Else
GetInfo = ""
End If
End Function
Private Sub testit()
' MsgBox "You live in " & GetInfo(LOCALE_SENGCOUNTRY) & _
' " (" & GetInfo(LOCALE_SNATIVECTRYNAME) & ")," & vbCrLf & "and you speak " & GetInfo(LOCALE_SENGLANGUAGE) & _
' " (" & GetInfo(LOCALE_SNATIVELANGNAME) & ").", vbInformation 'WORKS CORRECTLY
' MsgBox ("UserDefault: " & GetInfo(LOCALE_USER_DEFAULT)) 'STILL EMPTY STRING
MsgBox ("SDecimal: " & GetInfo(LOCALE_SDECIMAL)) 'RETURNS "."
' MsgBox ("ILDate: " & GetInfo(LOCALE_ILDATE)) 'RETURNS "0"
' MsgBox ("Country: " & GetInfo(LOCALE_ICOUNTRY)) 'RETURNS "1"
End Sub