using System;
/// <summary>
/// freeware helper class for getting OS info
/// (W) 2011 by admin of codezentrale.de
/// </summary>
public static class OSVersion
{
/// <summary>
/// version string for current system
/// </summary>
public static string VersionString
{
get
{
string sRetVal = string.Empty;
Version osver = Environment.OSVersion.Version;
switch (Environment.OSVersion.Platform)
{
// Windows 95 wird von .NET nicht unterstützt
// Windows 98, Windows 98SE, Windows Me
case PlatformID.Win32Windows:
if (osver.Major == 4)
{
switch (osver.Minor)
{
case 10: sRetVal = "Windows 98"; break;
case 90: sRetVal = "Windows Me"; break;
}
}
break;
case PlatformID.Win32NT:
// Windows NT 3.51 wird von .NET nicht unterstützt
// Windows NT 4.0
if (osver.Major == 4) sRetVal = "Windows NT 4.0";
// Windows 2000, XP, Server 2003
if (osver.Major == 5)
{
switch (osver.Minor)
{
case 0: sRetVal = "Windows 2000"; break;
case 1: sRetVal = "Windows XP"; break;
case 2: sRetVal = "Windows Server 2003"; break;
}
}
// Windows Vista, Windows Server 2008, Windows 7
if (osver.Major == 6)
{
switch (osver.Minor)
{
case 0: sRetVal = "Windows Vista / Windows Server 2008"; break;
case 1: sRetVal = "Windows 7 / Windows Server 2008 R2"; break;
case 2: sRetVal = "Windows 8 / Windows Server 2012"; break;
}
}
break;
}
if (sRetVal == string.Empty) sRetVal = "unbekannte oder von .NET nicht unterstützte Windows-Version";
else sRetVal += " [" + Environment.OSVersion.VersionString + ", rev " + osver.Revision.ToString() + "]";
return sRetVal;
}
}
}