The easiest thing to do is look at Environment.OSVersion.ToString() which returns the system's platform, major version, minor version, build, and revision number as in "Microsoft Windows NT 5.0.2195.0".
Unfortunately the platform (in this case, "Microsoft Windows NT") doesn't tell you the operating system. The following table lets you look up the operating system name based on the platform ID, major version, and minor version.
The GetOSVersion function shown in the following code uses this information to return the operating system name.Code:OS Platform ID Major Version Minor Version 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 WinXP 2 5 1 Win2003 2 5 2 Vista/Windows Server 2008 2 6 0
The following code shows how the example program uses function GetOSVersion and various Environment.OSVersion properties to get operating system version information.Code:Public Function GetOSVersion() As String Select Case Environment.OSVersion.Platform Case PlatformID.Win32S Return "Win 3.1" Case PlatformID.Win32Windows Select Case Environment.OSVersion.Version.Minor Case 0 Return "Win95" Case 10 Return "Win98" Case 90 Return "WinME" Case Else Return "Unknown" End Select Case PlatformID.Win32NT Select Case Environment.OSVersion.Version.Major Case 3 Return "NT 3.51" Case 4 Return "NT 4.0" Case 5 Select Case _ Environment.OSVersion.Version.Minor Case 0 Return "Win2000" Case 1 Return "WinXP" Case 2 Return "Win2003" End Select Case 6 Return "Vista/Win2008Server" Case Else Return "Unknown" End Select Case PlatformID.WinCE Return "Win CE" End Select End Function
Check the original thread hereCode:Private Sub Form1_Load(ByVal sender As System.Object, ByVal _ e As System.EventArgs) Handles MyBase.Load ' Get the Environment.OSVersion. Label1.Text = Environment.OSVersion.ToString() ' Get the interpreted version information. lblPlatform.Text = _ Environment.OSVersion.Platform.ToString lblOSVersion.Text = GetOSVersion() lblMajor.Text = _ Environment.OSVersion.Version.Major.ToString lblMinor.Text = _ Environment.OSVersion.Version.Minor.ToString lblBuild.Text = _ Environment.OSVersion.Version.Build.ToString lblRevision.Text = _ Environment.OSVersion.Version.Revision.ToString End Sub





Reply With Quote