Code
1public string getCpuInfo() //读取CPU信息
2 {
3 ManagementClass mobj = new ManagementClass("Win32_Processor");
4 ManagementObjectCollection moc = mobj.GetInstances();
5 foreach (ManagementObject mo in moc)
6 {
7 return mo.Properties["ProcessorId"].Value.ToString();
8 }
9 return "";
10 }
11 public string getHddInfo() //读取硬盘信息
12 {
13 ManagementClass mobj = new ManagementClass("Win32_PhysicalMedia");
14 ManagementObjectCollection moc = mobj.GetInstances();
15 foreach (ManagementObject mo in moc)
16 {
17 return mo.Properties["SerialNumber"].Value.ToString();
18 }
19 return "";
20 }
1public string getCpuInfo() //读取CPU信息
2 {
3 ManagementClass mobj = new ManagementClass("Win32_Processor");
4 ManagementObjectCollection moc = mobj.GetInstances();
5 foreach (ManagementObject mo in moc)
6 {
7 return mo.Properties["ProcessorId"].Value.ToString();
8 }
9 return "";
10 }
11 public string getHddInfo() //读取硬盘信息
12 {
13 ManagementClass mobj = new ManagementClass("Win32_PhysicalMedia");
14 ManagementObjectCollection moc = mobj.GetInstances();
15 foreach (ManagementObject mo in moc)
16 {
17 return mo.Properties["SerialNumber"].Value.ToString();
18 }
19 return "";
20 }