VB.NET - Code Samples - VB.NET Return Windows OS Version
Deteremine the running Windows OS
Synopsis:
The code below is a modification of the code found on http://support.microsoft.com/default.aspx?scid=kb;EN-US;189249. More details about the code can be found there.
The Code:
Private Enum OSType WinXP = 0 WinNT = 1 Win2K = 2 Win95 = 3 WinME = 4 Win98 = 5 Win98_2ndEd = 6 WinNT3 = 7 WinNT3_1 = 8 WinNT3_5 = 9 WinNT3_51 = 10 WinNT4_0 = 11 Win32s = 12 Win2K3 = 13 Win3_1 = 14 WinCE = 15 Unknown = 16 End Enum Private Function getOSVersion() As OSType osInfo = OSVersion With osInfo Select Case .Platform Case .Platform.Win32Windows Select Case (.Version.Minor) Case 0 Return OSType.Win95 Case 10 If .Version.Revision.ToString() = "2222A" Then Return OSType.Win98_2ndEd Else Return OSType.Win98 End If Case 90 Return OSType.WinME End Select Case .Platform.Win32NT Select Case (.Version.Major) Case 3 Select Case Environment.OSVersion.Version.Minor Case 0 Return OSType.WinNT3 Case 1 Return OSType.WinNT3_1 Case 5 Return OSType.WinNT3_5 Case 51 Return OSType.WinNT3_51 End Select Case 4 Return OSType.WinNT4_0 Case 5 Select Case (.Version.Minor) Case 0 Return OSType.Win2K Case 1 Return OSType.WinXP Case 2 Return OSType.Win2K3 End Select Case Else Return OSType.Unknown End Select Case PlatformID.Win32S Return OSType.Win3_1 Case PlatformID.WinCE Return OSType.WinCE End Select End With End Function