Option Explicit

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type

'Platform IDs
Private Const WIN_ID_31 = 0
Private Const WIN_ID_95_98_ME = 1
Private Const WIN_ID_NT_2K_XP = 2

Public Sub TellWindowsVersion()
Dim lVer As OSVERSIONINFO

lVer.dwOSVersionInfoSize = Len(lVer)

Call GetVersionEx(lVer)

With lVer
Select Case .dwPlatformId
Case WIN_ID_31
MsgBox "Windows 3.x"

Case WIN_ID_95_98_ME
Select Case .dwMinorVersion
Case 0: MsgBox "Windows 95"
Case 10: MsgBox "Windows 98"
Case 90: MsgBox "Windows Me"
End Select

Case WIN_ID_NT_2K_XP
Select Case True
Case (.dwMajorVersion < 5)
MsgBox "Windows NT"
Case (.dwMajorVersion = 5)
Select Case .dwMinorVersion
Case 0: MsgBox "Windows 2000"
Case 1: MsgBox "Windows XP"
End Select
End Select

End Select
End With

End Sub

Private Sub Form_Load()
Call TellWindowsVersion
End Sub
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。