av手机免费在线观看,国产女人在线视频,国产xxxx免费,捆绑调教一二三区,97影院最新理论片,色之久久综合,国产精品日韩欧美一区二区三区

操作系統(tǒng)

C#檢測操作系統(tǒng)版本的方法

時(shí)間:2025-05-30 14:01:12 操作系統(tǒng) 我要投稿
  • 相關(guān)推薦

C#檢測操作系統(tǒng)版本的方法匯總

  本文實(shí)例為大家分享了C#檢測操作系統(tǒng)版本的方法,供大家參考,具體內(nèi)容如下

  我們通過System.Environment.OSVersion.Version獲得操作系統(tǒng)的版本號(hào),然后再根據(jù)版本號(hào)進(jìn)行判斷操作系統(tǒng)是什么版本。

  Version 類的屬性

  參考于:https://msdn.microsoft.com/zh-cn/library/windows/desktop/ms724834(v=vs.85).aspx

  注意:在msdn官方文檔有說明 → OSVersion 屬性報(bào)告兩個(gè)相同的版本號(hào) (6.2.0.0) Windows 8 和 Windows 8.1。在某些情況下, OSVersion 屬性可能不會(huì)返回與指定的 Windows 程序兼容性模式功能的版本相匹配的操作系統(tǒng)版本。

  代碼:

  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 檢測系統(tǒng)new GetOSystem();#endregion}}

  輸出結(jié)果:

  以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持。

【C#檢測操作系統(tǒng)版本的方法】相關(guān)文章:

c#檢測cpu使用率01-02

KMP算法的C#實(shí)現(xiàn)方法04-11

獲取當(dāng)前操作系統(tǒng)的軟件版本08-11

Linux操作系統(tǒng)的十個(gè)經(jīng)典版本08-01

WindowsMobile操作系統(tǒng)手機(jī)版本分類對應(yīng)機(jī)型01-26

Linux查看系統(tǒng)版本的方法06-26

快速安裝操作系統(tǒng)的方法07-09

操作系統(tǒng)打補(bǔ)丁的方法06-04

unix操作系統(tǒng)關(guān)機(jī)方法04-12