|
|
Title | Use the GetVersionExA API function to get the operating system version |
Keywords | GetVersionExA, OS version, operating system version |
Categories | Software 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:
OS | dwPlatformID | dwMajorVersion | dwMinorVersion |
Win3.1 | 0 | ? | ? |
Win95 | 1 | 4 | 0 |
Win98 | 1 | 4 | 10 |
WinME | 1 | 4 | 90 |
NT 3.51 | 2 | 3 | 51 |
NT 4.0 | 2 | 4 | 0 |
Win2000 | 2 | 5 | 0 |
|
|
' 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
|
|
|
|
|
|