|
|
Title | Get the operating system version in VB .NET |
Description | This example shows how to get the operating system version in VB .NET. It uses the System.Environment.OSVersion object's properties and methods. |
Keywords | OS, OS version, operating system, operating system version |
Categories | VB.NET, Windows |
|
|
Examine System.Environment.OSVersion object's Platform property to see whether the system is a form of Win32 or WinNT. Examine Version.Minor, Version.Major, and Version.Revision.ToString() to see which flavor.
|
|
' Set the OS version information.
Public Function GetVersion() As String
Dim os_version As OperatingSystem = OSVersion
With os_version
Select Case .Platform
Case .Platform.Win32Windows
' Win32.
Select Case (.Version.Minor)
Case 0
Return "Windows 95"
Case 10
If .Version.Revision.ToString() = _
"2222A" Then
Return "Windows 98 Second " & _
"Edition"
Else
Return "Windows 98"
End If
Case 90
Return "Windows Me"
End Select
Case .Platform.Win32NT
' WinNT.
Select Case (.Version.Major)
Case 3
Return "Windows NT 3.51"
Case 4
Return "Windows NT 4.0"
Case 5
Select Case (.Version.Minor)
Case 0
Return "Windows 2000"
Case 1
Return "Windows XP"
Case 2
Return "Windows Server 2003"
End Select
Case Else
Return "Unknown"
End Select
Case Else
Return "Unknown"
End Select
End With
End Function
|
|
See Knowledge Base article 304289 How To Determine Windows Version with VB.NET.
|
|
|
|
|
|