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 GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
Dim Info As OSVERSIONINFO, strOs As String
Dim Retval As Long, Result As String
Me.AutoRedraw = True
Info.dwOSVersionInfoSize = Len(Info)
Retval = GetVersionEx(Info)
If Retval = 0 Then MsgBox "Error": Exit Sub
Select Case Info.dwPlatformId
Case 0
strOs = "Windows 3.x"
Case 1
If (Info.dwMinorVersion = 0) Then
strOs = "Windows 95"
End If
If (Info.dwMinorVersion = 10) Then
strOs = "Windows 98"
End If
If (Info.dwMinorVersion = 90) Then
strOs = "Windows ME"
End If
Case 2
If (Info.dwMajorVersion < 5) Then
strOs = "Windows NT"
End If
If (Info.dwMajorVersion = 5 And Info.dwMinorVersion = 0) Then
strOs = "Windows 2K"
End If
If (Info.dwMajorVersion = 5 And Info.dwMinorVersion = 1) Then
strOs = "Windows XP"
End If
End Select
Text1.Text = strOs
Result = Str$(Info.dwMajorVersion) + "." + LTrim(Str(Info.dwMinorVersion))
Text2.Text = Result
End Sub