通过Environment.OSVersion 可获取当前电脑的版本信息
public string OpName()
{
OperatingSystem myos = Environment.OSVersion;
if (myos.Version.Major == 5)
{
if (myos.Version.Minor == 0) { return "Windows 2000 " + myos.ServicePack; }
else if (myos.Version.Minor == 1) { return "Windows XP " + myos.ServicePack; }
else if (myos.Version.Minor == 2) { return "Windows Server 2003 " + myos.ServicePack; }
else { return myos.ToString() + " " + myos.ServicePack; }
}
else { return myos.VersionString + " " + myos.ServicePack; }
}