'以下为获取操作系统版本声明
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long 'Specifies the length, in bytes, of the structure.
dwMajorVersion As Long 'Major Version Number
dwMinorVersion As Long 'Minor Version Number
dwBuildNumber As Long 'Build Version Number
dwPlatformId As Long 'Operating System Running, see below
szCSDVersion As String * 128 'Windows NT: Contains a null-terminated string,
'such as "Service Pack 3", that indicates the latest
'Service Pack installed on the system.
'If no Service Pack has been installed, the string is empty.
'Windows 95: Contains a null-terminated string that provides
'arbitrary additional information about the operating system
End Type
Private Const hNull = 0
' dwPlatformId defines:
Public Enum enuOSVersion
VER_PLATFORM_WIN32s = 0 'Win32s on Windows 3.1.
VER_PLATFORM_WIN32_WINDOWS = 1 'Win32 on Windows 95 or Windows 98.
'For Windows 95, dwMinorVersion is 0.
'For Windows 98, dwMinorVersion is 1.
VER_PLATFORM_WIN32_NT = 2 'Win32 on Windows NT.
End Enum
Private Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
'获取操作系统版本
Function GetOSVersion(Optional sInfo As String) As enuOSVersion
'=======================================
'Returns the Operating System being used
'1 = Windows 95 / Windows 98
'2 = Windows NT
'=======================================
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
With osinfo
.dwOSVersionInfoSize = 148
.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)
GetOSVersion = .dwPlatformId
sInfo = "Version " & .dwMajorVersion & "." & .dwMinorVersion & " (Build " & .dwBuildNumber & ": " & StrZToStr(.szCSDVersion) & ")"
End With
End Function
Function GetRunApp() As String
Select Case GetOSVersion()
Case VER_PLATFORM_WIN32_WINDOWS
GetRunApp = GetRunApp95()
Case VER_PLATFORM_WIN32_NT
GetRunApp = GetRunAppNT()
End Select
End Function
function GetRunApp95()
9x代码
function GetRunAppNT()
2000代码