国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#如何檢測操作系統版本

2019-10-29 21:20:09
字體:
來源:轉載
供稿:網友

本文實例為大家分享了C#檢測操作系統版本的方法,供大家參考,具體內容如下

我們通過System.Environment.OSVersion.Version獲得操作系統的版本號,然后再根據版本號進行判斷操作系統是什么版本。

Version 類的屬性

C#檢測操作系統版本,C#檢測系統版本,C#檢測版本

C#檢測操作系統版本,C#檢測系統版本,C#檢測版本

參考于:https://msdn.microsoft.com/zh-cn/library/windows/desktop/ms724834(v=vs.85).aspx
注意:在msdn官方文檔有說明 → OSVersion 屬性報告兩個相同的版本號 (6.2.0.0) Windows 8 和 Windows 8.1。在某些情況下, OSVersion 屬性可能不會返回與指定的 Windows 程序兼容性模式功能的版本相匹配的操作系統版本。
代碼:

public class GetOSystem{private const string Windows2000 = "5.0";private const string WindowsXP = "5.1";private const string Windows2003 = "5.2";private const string Windows2008 = "6.0";private const string Windows7 = "6.1";private const string Windows8OrWindows81 = "6.2";private const string Windows10 = "10.0";private string OSystemName;public void setOSystemName(string oSystemName){this.OSystemName = oSystemName;}public GetOSystem(){switch (System.Environment.OSVersion.Version.Major + "." + System.Environment.OSVersion.Version.Minor){case Windows2000:setOSystemName("Windows2000");break;case WindowsXP:setOSystemName("WindowsXP");break;case Windows2003:setOSystemName("Windows2003");break;case Windows2008:setOSystemName("Windows2008");break;case Windows7:setOSystemName("Windows7");break;case Windows8OrWindows81:setOSystemName("Windows8.OrWindows8.1");break;case Windows10:setOSystemName("Windows10");break;}Console.WriteLine(OSystemName);}}class Program{static void Main(string[] args){#region 檢測系統new GetOSystem();#endregion}}

輸出結果:

C#檢測操作系統版本,C#檢測系統版本,C#檢測版本

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到c#教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 定边县| 阿拉善右旗| 桐柏县| 浙江省| 武威市| 乃东县| 拉孜县| 开鲁县| 额尔古纳市| 望城县| 灵川县| 富顺县| 垫江县| 射洪县| 东阿县| 邯郸市| 武胜县| 客服| 石门县| 东台市| 常德市| 孝义市| 济南市| 盐津县| 观塘区| 承德市| 石楼县| 马公市| 民和| 通化市| 启东市| 肥西县| 古田县| 芜湖县| 广元市| 景宁| 辽源市| 洪洞县| 康平县| 桐乡市| 铜陵市|