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

首頁 > 編程 > C# > 正文

C# 獲取硬件參數的實現方法

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

C# 獲取硬件參數的實現方法

示例代碼:

private static string GetIdentifier(string wmiClass, string wmiProperty, string wmiMustBeTrue)     {       string result = "";       System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass);       System.Management.ManagementObjectCollection moc = mc.GetInstances();       foreach (System.Management.ManagementObject mo in moc)       {         if (mo[wmiMustBeTrue].ToString() == "True")         {           //Only get the first one           if (result == "")           {             try             {               result = mo[wmiProperty].ToString();               break;             }             catch             {             }           }         }       }       return result;     }       private static string GetIdentifier(string wmiClass, string wmiProperty)     {       string result = "";       System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass);       System.Management.ManagementObjectCollection moc = mc.GetInstances();       foreach (System.Management.ManagementObject mo in moc)       {         //Only get the first one         if (result == "")         {           try           {             result = mo[wmiProperty].ToString();             break;           }           catch           {           }         }       }       return result;     }       // cpu id  GetIdentifier("Win32_Processor", "UniqueId");   //processor id GetIdentifier("Win32_Processor", "ProcessorId");   //processor name GetIdentifier("Win32_Processor", "Name");     //Manufacturer GetIdentifier("Win32_Processor", "Manufacturer");     //BIOS Identifier     private static string GetBiosId()     {       return GetIdentifier("Win32_BIOS", "Manufacturer")       + GetIdentifier("Win32_BIOS", "SMBIOSBIOSVersion")       + GetIdentifier("Win32_BIOS", "IdentificationCode")       + GetIdentifier("Win32_BIOS", "SerialNumber")       + GetIdentifier("Win32_BIOS", "ReleaseDate")       + GetIdentifier("Win32_BIOS", "Version");     }     //Main physical hard drive ID     private static string GetDiskId()     {       return GetIdentifier("Win32_DiskDrive", "Model")       + GetIdentifier("Win32_DiskDrive", "Manufacturer")       + GetIdentifier("Win32_DiskDrive", "Signature")       + GetIdentifier("Win32_DiskDrive", "TotalHeads");     }     //Motherboard ID     private static string GetBaseId()     {       return GetIdentifier("Win32_BaseBoard", "Model")       + GetIdentifier("Win32_BaseBoard", "Manufacturer")       + GetIdentifier("Win32_BaseBoard", "Name")       + GetIdentifier("Win32_BaseBoard", "SerialNumber");     }     //Primary video controller ID     private static string GetVideoId()     {       return GetIdentifier("Win32_VideoController", "DriverVersion")       + GetIdentifier("Win32_VideoController", "Name");     }     //First enabled network card ID     private static string GetMacId()     {       return GetIdentifier("Win32_NetworkAdapterConfiguration", "MACAddress", "IPEnabled");     } 

如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!


注:相關教程知識閱讀請移步到c#教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南郑县| 武冈市| 红河县| 三台县| 剑河县| 巴中市| 茶陵县| 尚义县| 昌图县| 大新县| 金寨县| 丹凤县| 临清市| 勐海县| 洛宁县| 祥云县| 南和县| 临海市| 恩平市| 南木林县| 定陶县| 黄浦区| 邹城市| 南宁市| 德保县| 喀喇沁旗| 商水县| 孟津县| 鄂托克旗| 横山县| 南投县| 马尔康县| 建德市| 琼海市| 泗水县| 沽源县| 嘉定区| 大姚县| 邹城市| 北安市| 东城区|