System Programing

 

Saturday, May 30, 2009

Get OS version

// Get OS version

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
}

No comments:

Post a Comment

All Menu