命名空间:System.Management
/// <summary>
/// 获取硬盘序列号
/// </summary>
/// <returns></returns>
private static string GetDiskSerialNum()
{
ManagementObjectSearcher manos = new ManagementObjectSearcher();
manos.Query = new SelectQuery("Win32_DiskDrive", "", new string[] { "PNPDeviceID", "Signature" });
ManagementObjectCollection tempCollection = manos.Get();
ManagementObjectCollection.ManagementObjectEnumerator manoe = tempCollection.GetEnumerator();
manoe.MoveNext();
ManagementBaseObject manbo = manoe.Current;
string diskSerial = manbo.Properties["signature"].Value.ToString().Trim();
return diskSerial;
}