开发者

CPU Identification on Virtual Machine

开发者 https://www.devze.com 2023-03-11 01:23 出处:网络
I use following c# code to get processor information. The Management class is null if I run my ap开发者_运维知识库plication on a virtual machine. I use Oracle VM VirtualBox as my virtual pc (Windows X

I use following c# code to get processor information. The Management class is null if I run my ap开发者_运维知识库plication on a virtual machine. I use Oracle VM VirtualBox as my virtual pc (Windows XP SP3)

System.Management.ManagementClass Management = new System.Management.ManagementClass("Win32_Processor");

Does anyone has experience about using such code and has problems in virtual machines.


Oracle VirtualBox does not provide such information.

Here is the related ticket.

https://www.virtualbox.org/ticket/9046


Are you using GetInstances?

System.Management.ManagementClass ManagementClass1 = new System.Management.ManagementClass("Win32_Processor");

System.Management.ManagementObjectCollection ManagementObjectCollection1 = ManagementClass1.GetInstances();

foreach (System.Management.ManagementObject managementobject in ManagementObjectCollection1) {
    Console.Out.WriteLine(managementobject.Properties["Name"].Value);
}

Console.In.ReadLine();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号