如何通过代码确定硬件虚拟化是否可用?(C#, C++) [英] How to determine if hardware virtualization is available via code? (C#, C++)
问题描述
如何通过代码检测系统是否支持硬件虚拟化?(最好使用 C# 或 C++).
How can I detect if a system supports hardware virtualization via code? (Preferably in C# or C++).
我尝试使用 WMI 和 ManagementObjectSearcher,但找不到似乎表示机器中是否存在虚拟化支持的属性.
I tried using WMI and ManagementObjectSearcher, and could not find a property that seemed to represent if virtualization support was present or not in the machine.
奖金问题:是否可以判断 CPU 是否支持硬件虚拟化,但在 BIOS 中被禁用?
Bonus question: Is it possible to tell if the CPU supports HW virtualization, but disabled in BIOS?
推荐答案
我认为原发帖者是在问如何检测计算机硬件是否支持虚拟化,而不是在虚拟机内运行.请参阅这个问题以获得可能的答案.
I think the original poster is asking how to detect that the computer hardware supports virtualisation, not that it is running inside a virtual machine. See this question for a possible answer.
此外,如果您可以检查 CPU 标志,可能值得一看,因为如果处理器支持,将会有 Intel vmx
标志或 AMD svm
标志虚拟化扩展.我不能说我知道在 Windows 下应该怎么做,但是可以在 Linux 上的 /proc/cpuinfo
中找到这些信息.
Also, it might be worth seeing if you can check the CPU flags, as there will either be the Intel vmx
flag or the AMD svm
flag if the processor supports virtualisation extensions. I can't say I know how this should be done under Windows, but the information is available in /proc/cpuinfo
on Linux.
这篇关于如何通过代码确定硬件虚拟化是否可用?(C#, C++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!