ASP.NET 获取主硬盘序列号

来源:百度知道 编辑:UC知道 时间:2024/06/17 17:58:41
ASP.NET 怎样获取主硬盘序列号

using System;
using System.Text.RegularExpressions;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Collections.Generic;
using System.Management;

//获取硬盘ID
String HDid;
ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive");
ManagementObjectCollection moc1 = cimobject1.GetInstances();
foreach (ManagementObject mo in moc1)
{
HDid = (string) mo.Properties["Model"].Value;
Console.WriteLine("硬盘序列号:" + HDid.ToString());
}