Private Declare Function GetUserDefaultLCID Lib "kernel32" () As Long
Private Declare Function GetThreadLocale Lib "kernel32" () As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _
(ByVal lpLibFileName As String) As Long
Private Declare Function LoadString Lib "user32" Alias "LoadStringA" _
(ByVal hInstance As Long, ByVal wID As Long, ByVal lpBuffer As String, _
ByVal nBufferMax As Long) As Long
Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" _
(ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, _
ByVal cchData As Long) As Long
Function GetCharSet(sCdpg As String) As Integer
Select Case sCdpg
Case "932" ' Japanese
GetCharSet = SHIFTJIS_CHARSET
Case "936" ' Simplified Chinese
GetCharSet = GB2312_CHARSET
Case "949" ' Korean
GetCharSet = HANGEUL_CHARSET
Case "950" ' Traditional Chinese
GetCharSet = CHINESEBIG5_CHARSET
Case "1250" ' Eastern Europe
GetCharSet = EASTEUROPE_CHARSET
Case "1251" ' Russian
GetCharSet = RUSSIAN_CHARSET
Case "1252" ' Western European Languages
GetCharSet = ANSI_CHARSET
Case "1253" ' Greek
GetCharSet = GREEK_CHARSET
Case "1254" ' Turkish
GetCharSet = TURKISH_CHARSET
Case "1255" ' Hebrew
GetCharSet = HEBREW_CHARSET
Case "1256" ' Arabic
GetCharSet = ARABIC_CHARSET
Case "1257" ' Baltic
GetCharSet = BALTIC_CHARSET
Case Else
GetCharSet = 0
End Select
End Function
Function StripNullTerminator(sCP As String)
Dim posNull As Long
posNull = InStr(sCP, Chr$(0))
StripNullTerminator = Left$(sCP, posNull - 1)
End Function
Private Sub Form_Load()
Dim hInst As Long, lResult As Long, x As Long
Dim LCID As Long, sLcid As String
Dim resString As String * 255
Dim sCodePage As String
sLcid = Hex$(Trim$(CStr(LCID))) 'Convert to Hex
' Display decimal value of the LCID (Hex in Parentheses)
Form1.Caption = "LCID " & LCID & " (" & sLcid & ")"
x = GetLocaleInfo(LCID, LOCALE_IDEFAULTANSICODEPAGE, _
sCodePage, Len(sCodePage)) 'Get code page
sCodePage = StripNullTerminator(sCodePage)
' Load dll with string table resource.
' Might need to change path for the resdll.
hInst = LoadLibrary("resdll" & sLcid & ".dll")
' Get string with ID 101.
lResult = LoadString(hInst, 101, resString, 255)
With Label1.Font
.Name = "Lucida Sans Unicode"
.Size = 14
.Charset = GetCharSet(sCodePage) 'Convert code page to charset
End With
' Display the localized string.
Label1.Caption = resString
With Text1.Font
.Name = "Tahoma"
.Charset = SYMBOL_CHARSET
.Size = 14
End With