Private Type OSVersionInfo
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformID As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVersionInfo) As Integer
Public Function OperatingSystem() As Integer
Dim OSInfo As OSVersionInfo
Dim RetValue As Integer
OSInfo.dwOSVersionInfoSize = 148
OSInfo.szCSDVersion = Space$(128)
RetValue = GetVersionExA(OSInfo)
With OSInfo
Select Case .dwPlatformID
Case 1
If .dwMinorVersion = 0 Then
OperatingSystem = Windows95
ElseIf .dwMinorVersion = 10 Then
OperatingSystem = Windows98
End If
Case 2
If .dwMajorVersion = 3 Then
OperatingSystem = WindowsNT3
ElseIf .dwMajorVersion = 4 Then
OperatingSystem = WindowsNT4
ElseIf .dwMinorVersion = 1 Then
OperatingSystem = WindowsXP ' Win XP
ElseIf .dwMinorVersion = 0 Then
OperatingSystem = Windows2000 ' Win 2000
End If
Case Else
OperatingSystem = 0
End Select
End With
End Function