以编程方式检测是否在 Windows 上启用了 VT-x 或 AMD-v
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21537769/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Programatically detect if VT-x or AMD-v is enabled on Windows
提问by chromic
On OSX or linux, it is rather trivial to view CPU capabilities in the terminal. Is there a way to access the CPU information, specifically the hardware assisted virtualization capabilities, on Windows?
在 OSX 或 linux 上,在终端中查看 CPU 功能相当简单。有没有办法在 Windows 上访问 CPU 信息,特别是硬件辅助虚拟化功能?
I only found Microsoft's tool: http://www.microsoft.com/en-us/download/details.aspx?id=592
我只找到了微软的工具:http: //www.microsoft.com/en-us/download/details.aspx?id=592
but would like something that doesn't require additional binaries.
但想要一些不需要额外二进制文件的东西。
回答by TheSpaceMoth
I believe the best bet to check if virtualisation is enabled is by using WMI and check the Win32_Processor class. The value of the "VirtualizationFirmwareEnabled" field should give you if it is enabled.
我相信检查是否启用虚拟化的最佳方法是使用 WMI 并检查 Win32_Processor 类。如果启用,“VirtualizationFirmwareEnabled”字段的值应该给你。
I have tested on my machine by enabling and disabling in the BIOS and this value appears correct.
我已经通过在 BIOS 中启用和禁用在我的机器上进行了测试,并且该值看起来是正确的。
Win32_Processor: http://msdn.microsoft.com/en-us/library/aa394373%28v=vs.85%29.aspx
Win32_Processor:http: //msdn.microsoft.com/en-us/library/aa394373%28v=vs.85%29.aspx
For checking what is supported I believe you will need to use the __cpuid() intrinsic function with an Information type of 0x1 and 0x80000001 to query the CPU features. Examples can be found on the following links.
为了检查支持的内容,我相信您需要使用信息类型为 0x1 和 0x80000001 的 __cpuid() 内部函数来查询 CPU 功能。可以在以下链接中找到示例。
CPUID Wiki: http://en.wikipedia.org/wiki/CPUID
CPUID 维基:http: //en.wikipedia.org/wiki/CPUID
__cpuid Function: msdn.microsoft.com/en-us/library/hskdteyh(VS.80).aspx
__cpuid 函数:msdn.microsoft.com/en-us/library/hskdteyh(VS.80).aspx