我正在尝试使用此代码:
public string GetCPUId()
{
string cpuInfo = String.Empty;
string temp = String.Empty;
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (cpuInfo == String.Empty)
{
cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
}
}
return cpuInfo;
}
在 XP 虚拟机(virtualbox)上获取硬件 uid,但我只得到一个消息框,上面写着:
Object reference not set to an instance of an object.
是因为它是虚拟机还是什么?