|
-
Nov 25th, 2001, 10:05 AM
#1
versions again
I found the following code but when I run it on a windows ME machine, it tells me that windows 98 is the operating system.
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
Public Const VER_PLATFORM_WIN32s = 0
Public Const VER_PLATFORM_WIN32_WINDOWS = 1
Public Const VER_PLATFORM_WIN32_NT = 2
Public Sub GetVersionInformation()
Dim OSInfo As OSVERSIONINFO
Dim lngRetVal As Long
Dim PId As String, tmpStrInfo As String
OSInfo.dwOSVersionInfoSize = Len(OSInfo)
lngRetVal = CLng(GetVersionEx(OSInfo))
If lngRetVal = 0 Then MsgBox "Error Getting Version Information": Exit Sub
Select Case OSInfo.dwPlatformId
Case VER_PLATFORM_WIN32_NT
' This is an NT version (NT/2000)
' If dwMajorVersion >= 5 then
' the OS is Win2000
If OSInfo.dwMajorVersion >= 5 Then
PId = "Windows 2000"
Else
PId = "Windows NT"
End If
Case Else
' This is Windows 95/98/ME
If OSInfo.dwMajorVersion >= 5 Then
PId = "Windows ME"
ElseIf OSInfo.dwMajorVersion = 4 And OSInfo.dwMinorVersion > 0 Then
PId = "Windows 98"
Else
PId = "Windows 95"
End If
End Select
tmpStrInfo = "OS: " & PId & vbCrLf
tmpStrInfo = tmpStrInfo & "Windows version:" & _
CStr(OSInfo.dwMajorVersion) + "." & _
LTrim(CStr(OSInfo.dwMinorVersion)) & vbCrLf
tmpStrInfo = tmpStrInfo & "Build: " + CStr(OSInfo.dwBuildNumber) & vbCrLf _
& OSInfo.szCSDVersion
'MsgBox tmpStrInfo, , "System Statistics"
OsVersion = PId
End Sub
Please point me towards the Major and Minor version numbers.
Thanx
-
Nov 25th, 2001, 10:08 AM
#2
Lively Member
Here is a table with all Windows version numbers:
Code:
dwMajorVersion
Operating System Value
--------------------------------------------------------
Windows 95 4
Windows 98 4
Windows 98 SE 4
Windows Me 4
Windows NT 3.51 3
Windows NT 4.0 4
Windows 2000 5
Windows XP 5
dwMinorVersion
Operating System Value
--------------------------------------------------------
Windows 95 0
Windows 98 10
Windows 98 SE 10
Windows Me 90
Windows NT 3.51 51
Windows NT 4.0 0
Windows 2000 0
Windows XP 1
dwPlatformId
Operating System Value
--------------------------------------------------------
Windows NT 0
Windows 32 1
Windows XP 2
Last edited by floppes; Nov 25th, 2001 at 10:12 AM.
-
Nov 25th, 2001, 10:09 AM
#3
PowerPoster
try this, see what you get
VB Code:
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|