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
Dim OSV As OSVERSIONINFO
Public Function GetOSVersion() As String
Dim nOSVersion As Integer
Dim lResult As Long
OSV.dwOSVersionInfoSize = Len(OSV)
lResult = GetVersionEx(OSV)
nOSVersion = OSV.dwPlatformId
Select Case OSV.dwPlatformId
Case 1
Select Case OSV.dwMinorVersion
Case 0
GetOSVersion = "Win95"
Case 10
GetOSVersion = "Win98"
Case 90
GetOSVersion = "WinMe"
End Select
Case 2
Select Case OSV.dwMinorVersion
Case 0
GetOSVersion = "WinNT4"
Case 51
GetOSVersion = "WinNT3.51"
End Select
If OSV.dwMajorVersion = 5 Then
GetOSVersion = "Win2000"
End If
End Select
' Win95 Win98 WinMe WinNT 3.51 WinNT 4.0 Win 2000
' dwPlatformID 1 1 1 2 2 2
' dwMajorVersion 4 4 3 4 5
' dwMinorVersion 0 10 90 51 0 0
End Function