howto net os version
VB:
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
C#
public static string GetMachineOS()
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
if (Environment.OSVersion.Version.Major<=4)
return String.Format("Windows NT {0}", Environment.OSVersion.Version.ToString());
if (Environment.OSVersion.Version.Major==5)
{
if (Environment.OSVersion.Version.Minor==0)
return String.Format("Windows 2000 {0}", Environment.OSVersion.Version.ToString());
else
return String.Format("Windows XP {0}", Environment.OSVersion.Version.ToString());
}
}
if (Environment.OSVersion.Platform == PlatformID.Win32Windows)
{
if (Environment.OSVersion.Version.Major>=4)
{
if (Environment.OSVersion.Version.Minor==0)
return String.Format("Windows 95 {0}", Environment.OSVersion.Version.ToString());
else if (Environment.OSVersion.Version.Minor<90)
return String.Format("Windows 98 {0}", Environment.OSVersion.Version.ToString());
else
return String.Format("Windows Millenim Edition {0}", Environment.OSVersion.Version.ToString());
}
}
return Environment.OSVersion.ToString(); //ELSE
}