Results 1 to 3 of 3

Thread: versions again

  1. #1
    vbGrandpa
    Guest

    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

  2. #2
    Lively Member floppes's Avatar
    Join Date
    May 2001
    Location
    Darmstadt, Germany
    Posts
    99
    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.

  3. #3
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    try this, see what you get
    VB Code:
    1. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    2.  
    3. Private Type OSVERSIONINFO
    4.    dwOSVersionInfoSize As Long
    5.    dwMajorVersion As Long
    6.    dwMinorVersion As Long
    7.    dwBuildNumber As Long
    8.    dwPlatformId As Long
    9.    szCSDVersion As String * 128
    10. End Type
    11.  
    12. Dim OSV As OSVERSIONINFO
    13.  
    14. Public Function GetOSVersion() As String
    15.  
    16. Dim nOSVersion As Integer
    17. Dim lResult As Long
    18.    
    19.     OSV.dwOSVersionInfoSize = Len(OSV)
    20.     lResult = GetVersionEx(OSV)
    21.     nOSVersion = OSV.dwPlatformId
    22.    
    23.     Select Case OSV.dwPlatformId
    24.         Case 1
    25.             Select Case OSV.dwMinorVersion
    26.                 Case 0
    27.                     GetOSVersion = "Win95"
    28.                 Case 10
    29.                     GetOSVersion = "Win98"
    30.                 Case 90
    31.                     GetOSVersion = "WinMe"
    32.             End Select
    33.         Case 2
    34.             Select Case OSV.dwMinorVersion
    35.                 Case 0
    36.                     GetOSVersion = "WinNT4"
    37.                 Case 51
    38.                     GetOSVersion = "WinNT3.51"
    39.             End Select
    40.            
    41.             If OSV.dwMajorVersion = 5 Then
    42.                 GetOSVersion = "Win2000"
    43.             End If
    44.    End Select
    45.    
    46. '                Win95 Win98 WinMe WinNT 3.51 WinNT 4.0 Win 2000
    47. ' dwPlatformID     1     1     1     2          2         2
    48. ' dwMajorVersion   4     4           3          4         5
    49. ' dwMinorVersion   0    10    90    51          0         0
    50.    
    51.    
    52. 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
  •  



Click Here to Expand Forum to Full Width