WEB开发网
开发学院WEB开发ASP.NET 用C#来判断当前系统是XP还是WIN7 阅读

用C#来判断当前系统是XP还是WIN7

 2013-01-23 18:03:31 来源:WEB开发网   
核心提示: 直接提供Winform程序:OperatingSystem os = Environment.OSVersion;switch (os.Platform){case PlatformID.Win32Windows:switch (os.Version.Minor){case 0:label1.Text = "

 直接提供Winform程序:
OperatingSystem os = Environment.OSVersion;
switch (os.Platform)
{
case PlatformID.Win32Windows:
switch (os.Version.Minor)
{
case 0:
label1.Text = "Windows 95 ";
break;
case 10:
if (os.Version.Revision.ToString() == "2222A ")
label1.Text = "Windows 98 第二版 ";
else
label1.Text = "Windows 98 ";
break;
case 90:
label1.Text = "Windows Me ";
break;
}
break;
case PlatformID.Win32NT:
switch (os.Version.Major)
{
case 3:
label1.Text = "Windows NT 3.51 ";
break;
case 4:
label1.Text = "Windows NT 4.0 ";
break;
case 5:
switch (os.Version.Minor)
{
case 0:
label1.Text = "Windows 200 ";
break;
case 1:
label1.Text = "Windows XP ";
break;
case 2:
label1.Text = "Windows 2003 ";
break;
}
break;
case 6:
switch (os.Version.Minor)
{
case 0:
label1.Text = "Windows Vista ";
break;
case 1:
label1.Text = "Windows 7 ";
break;
}
break;
}
break;
}
当然,大家直接可以通过 OperatingSystem os = Environment.OSVersion;然后判断os.Version.Major是否是等于6,就可以判断系统是不是windows Vista以上版本

Tags:判断 当前 XP

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接