'Get Current System Default Language
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As LongPublic Enum EnumSystemLanguage
eslDefault = 0
eslHongKong = &HC04 '3076 SAR 950 ZHH
eslMacau = &H1404 '5124 SAR 950 ZHM
eslChinese = &H804 '2052 936 CHS
eslSingapore = &H1004 '4100 936 ZHI
eslTaiwan = &H404 '1028 950 CHT
eslEnglish = &H409 '1033
eslJapanese = &H411 '1041 Japan 932 JAPAN
eslKorean = &H412 '1042 Korea Unicode only KOREA
End EnumPublic Function GetDefaultLanguage() As EnumSystemLanguage
Dim lLCID As Long
lLCID = GetSystemDefaultLCID
GetDefaultLanguage = lLCID
End Function
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As LongPublic Enum EnumSystemLanguage
eslDefault = 0
eslHongKong = &HC04 '3076 SAR 950 ZHH
eslMacau = &H1404 '5124 SAR 950 ZHM
eslChinese = &H804 '2052 936 CHS
eslSingapore = &H1004 '4100 936 ZHI
eslTaiwan = &H404 '1028 950 CHT
eslEnglish = &H409 '1033
eslJapanese = &H411 '1041 Japan 932 JAPAN
eslKorean = &H412 '1042 Korea Unicode only KOREA
End EnumPublic Function GetDefaultLanguage() As EnumSystemLanguage
Dim lLCID As Long
lLCID = GetSystemDefaultLCID
GetDefaultLanguage = lLCID
End Function
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2002 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you many not reproduce
' or publish this code on any web site,
' online service, or distribute as source on
' any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Const LOCALE_SLANGUAGE As Long = &H2 'localized name of language
Public Const LOCALE_SABBREVLANGNAME As Long = &H3 'abbreviated language name
Public Const LCID_INSTALLED As Long = &H1 'installed locale ids
Public Const LCID_SUPPORTED As Long = &H2 'supported locale ids
Public Const LCID_ALTERNATE_SORTS As Long = &H4 'alternate sort locale idsPublic Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(Destination As Any, _
Source As Any, _
ByVal Length As Long)Public Declare Function GetSystemDefaultLCID Lib "kernel32" () As LongPublic Declare Function GetLocaleInfo Lib "kernel32" _
Alias "GetLocaleInfoA" _
(ByVal Locale As Long, _
ByVal LCType As Long, _
ByVal lpLCData As String, _
ByVal cchData As Long) As LongPublic Declare Function EnumSystemLocales Lib "kernel32" _
Alias "EnumSystemLocalesA" _
(ByVal lpLocaleEnumProc As Long, _
ByVal dwFlags As Long) As Long
Public Function GetUserLocaleInfo(ByVal dwLocaleID As Long, _
ByVal dwLCType As Long) As String Dim sReturn As String
Dim nSize As Long 'call the function passing the Locale type
'variable to retrieve the required size of
'the string buffer needed
nSize = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
'if successful..
If nSize Then
'pad a buffer with spaces
sReturn = Space$(nSize)
'and call again passing the buffer
nSize = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
'if successful (nSize > 0)
If nSize Then
'nSize holds the size of the string
'including the terminating null
GetUserLocaleInfo = Left$(sReturn, nSize - 1)
End If
End If
End Function
Public Function EnumSystemLocalesProc(lpLocaleString As Long) As Long 'application-defined callback function for EnumSystemLocales Dim pos As Integer
Dim dwLocaleDec As Long
Dim dwLocaleHex As String
Dim sLocaleName As String
Dim sLocaleAbbrev As String
'pad a string to hold the format
dwLocaleHex = Space$(32)
'copy the string pointed to by the return value
CopyMemory ByVal dwLocaleHex, lpLocaleString, ByVal Len(dwLocaleHex)
'locate the terminating null
pos = InStr(dwLocaleHex, Chr$(0))
If pos Then
'strip the null
dwLocaleHex = Left$(dwLocaleHex, pos - 1)
'we need the last 4 chrs - this
'is the locale ID in hex
dwLocaleHex = (Right$(dwLocaleHex, 4))
'convert the string to a long
dwLocaleDec = CLng("&H" & dwLocaleHex)
'get the language and abbreviation for that locale
sLocaleName = GetUserLocaleInfo(dwLocaleDec, LOCALE_SLANGUAGE)
sLocaleAbbrev = GetUserLocaleInfo(dwLocaleDec, LOCALE_SABBREVLANGNAME)
End If
'add the data to the list
Form1.List1.AddItem " " & dwLocaleHex & vbTab & _
dwLocaleDec & vbTab & _
sLocaleAbbrev & vbTab & _
sLocaleName
'and return 1 to continue enumeration
EnumSystemLocalesProc = 1
End Function
'--end block--'
Form Code
Create a form containing a text box (Text1), a command button (Command1) and a listbox (List1). Label as desired, and add the following code to the form: --------------------------------------------------------------------------------
Option ExplicitPrivate Sub Command1_Click() Dim LCID As Long
'get the user's current default ID
LCID = GetSystemDefaultLCID()
'show the current localized name of language
Text1.Text = GetUserLocaleInfo(LCID, LOCALE_SLANGUAGE) & vbTab & _
GetUserLocaleInfo(LCID, LOCALE_SABBREVLANGNAME)
'add a list caption, and enumerate the
'installed system locales
List1.AddItem "Installed Locales:"
List1.AddItem " hex" & vbTab & "dec" & vbTab & "abv" & vbTab & "language"
Call EnumSystemLocales(AddressOf EnumSystemLocalesProc, LCID_INSTALLED)
'add a list caption, and enumerate the
'supported system locales
List1.AddItem ""
List1.AddItem "Supported Locales:"
List1.AddItem " hex" & vbTab & "dec" & vbTab & "abv" & vbTab & "language"
Call EnumSystemLocales(AddressOf EnumSystemLocalesProc, LCID_SUPPORTED)
End Sub
'--end block--'
'1024 = Process Default Language
'1030 = Danish
'1031 = German (Standard)
'1032 = Greek
'1033 = English (United States)
'2057 = English (United Kingdom)
'3081 = English (Australian)
'4105 = English (Canadian)
'5129 = English (New Zealand)
'6153 = English (Ireland)
'7177 = English (South Africa)
'8201 = English (Jamaica)
'9225 = English (Caribbean)
'10249 = English (Belize)
'11273 = English (Trinidad)
'1034 = Spanish (Traditional Sort)
'3082 = Spanish (Modern Sort)
'1035 = Finnish
'1036 = French (Standard)
'1040 = Italian (Standard)
'1043 = Dutch (Standard)
'2067 = Dutch (Belgian)
'1044 = Norwegian (Bokmal)
'2068 = Norwegian (Nynorsk)
'1045 = Polish
'2070 = Portuguese (Standard)
'1049 = Russian
Private Declare Function VerLanguageName Lib "kernel32" Alias "VerLanguageNameA" (ByVal wLang As Long, ByVal szLang As String, ByVal nSize As Long) As Long
Private Sub Form_Paint()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim Buffer As String
Buffer = String(255, 0)
VerLanguageName 2067, Buffer, Len(Buffer)
Buffer = Left$(Buffer, InStr(1, Buffer, Chr$(0)) - 1)
MsgBox Buffer
End Sub
1)
Private Declare Function GetSystemDefaultLangID Lib "kernel32" () As Integer2)
dim langId as Integer
LangId = Hex(GetSystemDefaultLangID)3)
判断langId,根据tg123(T.G.) 所说的id
如:
Select Case mHLangId
Case 804 '简体中文
'do...