C#得到CPU的序列号、硬盘序列号、网卡序列号
public static void GetCpuIndex()
?{
??????????? string _cpuInfo = "";
??????????? ManagementClass cimobject = new ManagementClass("Win32_Processor");
??????????? ManagementObjectCollection moc = cimobject.GetInstances();
??????????? foreach (ManagementObject mo in moc)
??????????? {
??????????????? _cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
??????????? }??????????? return _cpuInfo;
}
// 得到硬盤序列號(hào)
public static void GetHDIndex()
?{
??????????? string _HDInfo = "";
??????????? ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive");
??????????? ManagementObjectCollection moc1 = cimobject1.GetInstances();
??????????? foreach (ManagementObject mo in moc1)
??????????? {
??????????????? _HDInfo = (string)mo.Properties["Model"].Value;
??????????? }
??????????? retrun _HDInfo;
}
//獲取網(wǎng)卡硬件地址
?public static void GetMacAddress()
?{
??????????? string _MacAddress = "";
??????????? ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
??????????? ManagementObjectCollection moc2 = mc.GetInstances();
??????????? foreach (ManagementObject mo in moc2)
??????????? {
??????????????? if ((bool)mo["IPEnabled"] == true)
??????????????????? MacAddress = mo["MacAddress"].ToString();
??????????????? mo.Dispose();
??????????? }
???????????
??????????? return _MacAddress;
?}
轉(zhuǎn)載于:https://www.cnblogs.com/zhangtao/archive/2011/03/06/1972397.html
總結(jié)
以上是生活随笔為你收集整理的C#得到CPU的序列号、硬盘序列号、网卡序列号的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: XP下Virtualbox虚拟Ubunt
- 下一篇: 微软软件安装平台