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

首頁 > 編程 > C# > 正文

C# 獲取硬件參數(shù)的實(shí)現(xiàn)方法

2020-01-24 00:26:42
字體:
供稿:網(wǎng)友

C# 獲取硬件參數(shù)的實(shí)現(xiàn)方法

示例代碼:

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");     } 

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

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 郁南县| 琼海市| 阿尔山市| 慈利县| 宜宾县| 新巴尔虎左旗| 丹凤县| 榆林市| 兴化市| 金沙县| 酒泉市| 库尔勒市| 华宁县| 西和县| 沙湾县| 神木县| 连江县| 行唐县| 措美县| 茌平县| 襄垣县| 鹤山市| 无锡市| 和平区| 肇源县| 福泉市| 资阳市| 石嘴山市| 大新县| 平阴县| 天门市| 都匀市| 赣州市| 濮阳县| 邻水| 玛多县| 桐城市| 芒康县| 北票市| 宣恩县| 永福县|