1. private string[] GetMoc()
2. {
3. string[] str = new string[3];
4. ManagementClass mcCpu = new ManagementClass("win32_Processor");
5. ManagementObjectCollection mocCpu = mcCpu.GetInstances();
6. foreach(ManagementObject m in mocCpu)
7. {
8. str[0] = m["UniqueID"].ToString();
9. }
10.
11. ManagementClass mcHD = new ManagementClass("win32_logicaldisk");
12. ManagementObjectCollection mocHD = mcHD.GetInstances();
13. foreach(ManagementObject m in mocHD)
14. {
15. if(m["DeviceID"].ToString() == "C:")
16. {
17. str[1] = m["VolumeSerialNumber"].ToString();
18. break;
19. }
20. }
21.
22. ManagementClass mcMAC = new ManagementClass("Win32_NetworkAdapterConfiguration");
23. ManagementObjectCollection mocMAC = mcMAC.GetInstances();
24. foreach(ManagementObject m in mocMAC)
25. {
26. if((bool)m["IPEnabled"])
27. {
28. str[2] = m["MacAddress"].ToString();
29. break;
30. }
31. }
32.
33. return str;
34. }
取消
评论