国产探花免费观看_亚洲丰满少妇自慰呻吟_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#教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 且末县| 穆棱市| 土默特右旗| 六盘水市| 雷山县| 波密县| 石渠县| 绍兴市| 儋州市| 图木舒克市| 收藏| 衡东县| 宽甸| 河东区| 澳门| 恩平市| 通化县| 准格尔旗| 肇东市| 客服| 巴中市| 新巴尔虎右旗| 金乡县| 盖州市| 兴和县| 寻甸| 明溪县| 三江| 南昌市| 从化市| 仙游县| 团风县| 灵川县| 中牟县| 宁强县| 江西省| 兴文县| 怀来县| 济南市| 蕲春县| 莱芜市|