///
/// 取得處理器編號
///
/// 處理器索引
///回傳處理器編號
public string GetCPUSerialNumber(int index)
{
string strCPUSerialNumber = "";
try
{
ManagementObject wmiObj = new ManagementObject(string.Format("Win32_Processor.DeviceID='CPU{0}'", index));
strCPUSerialNumber = wmiObj.GetPropertyValue("ProcessorId").ToString();
}
catch (Exception)
{
strCPUSerialNumber = "";
}
return strCPUSerialNumber;
}
Tips. 在VirtualBox中Win32 WMI是沒有被啟用的,所以執行此方法會產生NULL Exception
參閱:[vbox-trac] [VirtualBox] #6361: Win32_BaseBoard WMI Class Not Available
張貼留言