Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse the GetVersionExA API function to get the operating system version
KeywordsGetVersionExA, OS version, operating system version
CategoriesSoftware Engineering, Windows
 
Use the GetVersionExA API function. This function fills in a structure with dwPlatformID, dwMajorVersion, and dwMinorVersion properties that give the operating system version information:

OSdwPlatformIDdwMajorVersiondwMinorVersion
Win3.10??
Win95140
Win981410
WinME1490
NT 3.512351
NT 4.0240
Win2000250
 
' Return the OS version, build, and platform ID.
Public Sub GetOSVersion(ByRef os_version As String, ByRef _
    os_build As String, ByRef os_platformid As String)
Dim version_info As OSVERSIONINFO

    ' Get the information.
    version_info.dwOSVersionInfoSize = Len(version_info)
    GetVersionExA version_info

    ' See what it means.
    With version_info
        Select Case .dwPlatformId
            Case 0
                os_version = "Win 3.1"
            Case 1
                Select Case .dwMinorVersion
                    Case 0
                        os_version = "Win95"
                    Case 10
                        os_version = "Win98"
                    Case 90
                        os_version = "WinME"
                    Case Else
                        os_version = "Unknown"
                End Select
            Case 2
                Select Case .dwMajorVersion
                    Case 3
                        os_version = "NT_3.51"
                    Case 4
                        os_version = "NT_4.0"
                    Case 5
                        os_version = "Win2000"
                    Case Else
                        os_version = "Unknown"
                End Select
            Case Else
                os_version = "Unknown"
        End Select
    
        os_build = Format$(.dwBuildNumber)
        os_platformid = Format$(.dwPlatformId)
    End With
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated