1. // 获取硬盘号 2. private string GetDiskID() 3. { 4. try 5. { 6. // 获取硬盘 ID 7. StringHDid= "" ; 8. ManagementClassmc= new ManagementClass( "Win32_DiskDrive" ); 9. ManagementObjectCollectionmoc=mc.GetInstances(); 10. foreach (Manageme
1. //获取硬盘号
2. private string GetDiskID()
3. {
4. try
5. {
6. //获取硬盘ID
7. String HDid = "";
8. ManagementClass mc = new ManagementClass("Win32_DiskDrive");
9. ManagementObjectCollection moc = mc.GetInstances();
10. foreach (ManagementObject mo in moc)
11. {
12. HDid = (string)mo.Properties["Model"].Value;
13. }
14. moc = null;
15. mc = null;
16. return HDid;
17. }
18. catch
19. {
20. return "";
21. }
22. finally
23. {
24. }
25. }
26. //获取CPU信息
27. private string GetCpuInfo()
28. {
29. try
30. {
31. string cpuInfo = "";//cpu序列号
32. ManagementClass cimobject = new ManagementClass("Win32_Processor");
33. ManagementObjectCollection moc = cimobject.GetInstances();
34. foreach (ManagementObject mo in moc)
35. {
36. cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
37. }
38. return cpuInfo;
39. }
40. catch
41. {
42. this.senRegeditID.Enabled = false;
43. this.GetId.Enabled = true;
44. }
45.
46. return "";
47. }