通过 API 函数GetSystemDefaultLCID 判断系统的语言
Option Explicit
Dim lang As String
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Private Sub Form_Load()
Dim LocaleID As Long
LocaleID = GetSystemDefaultLCID
Select Case LocaleID
Case &H404
MsgBox "当前系统为:中文繁体", , "语言"
Case &H804
MsgBox "当前系统为:中文简体", , "语言"
lang = "1"
Case &H409
MsgBox "当前系统为:英文", , "语言"
lang = "2"
End Select
End Sub
The GetVersionEx function obtains extended information about the version of the operating system that is currently running.
To obtain information for the operating system on a remote computer, use the NetWkstaGetInfo function, the Win32_OperatingSystem WMI class, or the OperatingSystem property of the IADsComputer interface.
To compare the current system version to a required version, use the VerifyVersionInfo function instead of using GetVersionEx to perform the comparison yourself.
BOOL GetVersionEx(
LPOSVERSIONINFO lpVersionInfo
);
Parameters
lpVersionInfo
[in, out] Pointer to an OSVERSIONINFO data structure that the function fills with operating system version information.
Before calling the GetVersionEx function, set the dwOSVersionInfoSize member of this structure to sizeof(OSVERSIONINFO).
Windows NT 4.0 SP6 and later: This member can be a pointer to an OSVERSIONINFOEX structure. Set the dwOSVersionInfoSize member to sizeof(OSVERSIONINFOEX) to identify the structure type.
Return Values
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error information, call GetLastError. The function fails if you specify an invalid value for the dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure.
Remarks
Identifying the current operating system is usually not the best way to determine whether a particular operating system feature is present. This is because the operating system may have had new features added in a redistributable DLL. Rather than using GetVersionEx to determine the operating system platform or version number, test for the presence of the feature itself. For more information, see Operating System Version.
To verify whether the current operating system is either Windows XP Media Center Edition or Tablet PC Edition, use the GetSystemMetrics function.
Example Code [C++]
When using the GetVersionEx function to determine whether your application is running on a particular version of the operating system, check for version numbers that are greater than or equal to the desired version numbers. This ensures that the test succeeds for later versions of the operating system. For example, if your application requires Windows XP, use the following test.
Example Code
For an example that identifies the current operating system, see Getting the System Version.
Requirements
Client Requires Windows XP, Windows 2000 Professional, Windows NT Workstation 3.5 and later, Windows Me, Windows 98, or Windows 95.
Server Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 3.5 and later.
Header Declared in Winbase.h; include Windows.h.
Library Link to Kernel32.lib.
DLL Requires Kernel32.dll.
Unicode Implemented as GetVersionExW (Unicode) and GetVersionExA (ANSI). Note that Unicode support on Windows Me/98/95 requires Microsoft Layer for Unicode.