C# 獲得硬盤參數程序代碼如下:
public static void HardDisk(out string[] 制造商, out string[] 型號, out string[] 序列號)
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
制造商 = new string[searcher.Get().Count];
型號 = new string[searcher.Get().Count];
序列號 = new string[searcher.Get().Count];
int i = 0;
foreach (ManagementObject share in searcher.Get())
{
try
{
制造商[i] = share.GetPropertyValue("Manufacturer").ToString();
型號[i] = share.GetPropertyValue("Model").ToString();
序列號[i] = share.GetPropertyValue("Signature").ToString();
}
catch (System.Exception er)
{
}
i ;
}
}