国产探花免费观看_亚洲丰满少妇自慰呻吟_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#教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阿拉善左旗| 赣州市| 海晏县| 石城县| 南木林县| 赣榆县| 出国| 茌平县| 比如县| 万荣县| 兴国县| 彝良县| 彭州市| 大关县| 三明市| 明星| 浪卡子县| 三门县| 云阳县| 文山县| 广宗县| 河曲县| 绥滨县| 武汉市| 三原县| 邯郸市| 广东省| 贵德县| 望谟县| 米林县| 永德县| 襄城县| 桐庐县| 特克斯县| 图木舒克市| 凤台县| 宝丰县| 察哈| 南丰县| 鹿邑县| 南靖县|