代码
private String GetHardDiskID() { try { ManagementClass searcher = new ManagementClass("Win32_PhysicalMedia"); ManagementObjectCollection moc = searcher.GetInstances(); String strHardDiskID = ""; foreach (ManagementObject mo in moc) { strHardDiskID = mo["SerialNumber"].ToString().Trim(); break; } return strHardDiskID; } catch (Exception ex) { MessageBox.Show(ex.Message); return ""; } }