获取CPU及硬盘序列号

时间:2012-01-16 10:45:27
【文件属性】:

文件名称:获取CPU及硬盘序列号

文件大小:1KB

文件格式:TXT

更新时间:2012-01-16 10:45:27

CPU,硬盘,序列号

获取CPU及硬盘序列号 string Cpu_ID = ""; string Hard_Driver = ""; try { ManagementClass mcCpu = new ManagementClass("win32_Processor"); ManagementObjectCollection mocCpu = mcCpu.GetInstances(); foreach (ManagementObject m in mocCpu) { Cpu_ID = m["ProcessorId"].ToString(); break; } } catch { Cpu_ID = ""; } try { ManagementObjectSearcher mcDisk = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia"); ManagementObjectCollection mocDisk = mcDisk.Get(); foreach (ManagementObject mm in mocDisk) { Hard_Driver = mm["SerialNumber"].ToString().Trim(); break; } } catch { Hard_Driver = ""; }


网友评论

  • 是C#写的,代码不是很全
  • 代码写的不错
  • 不知道为什么 用不了啊
  • 是java版的呀,可惜不够详细啊,没有写要导入什么包