Take the 2-minute tour ×

How can I detect if a system supports hardware virtualization via code? (Preferably in C# or C++).

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.

Bonus question: Is it possible to tell if the CPU supports HW virtualization, but disabled in BIOS?

share|improve this question

5 Answers 5

up vote 2 down vote accepted

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.

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.

share|improve this answer

I do not have a C-ish answer, but here's a PowerShell approach -- it's just a simple WMI query -- that can help.

Query Win32_Processor; there are flags "SecondLevelAddressTranslationExtensions" and "VirtualizationFirmwareEnabled." They seem to answer the questions for me.

In PoSH, it's

(GWMI Win32_Processor).VirtualizationFirmwareEnabled


(GWMI Win32_Processor).SecondLevelAddressTranslationExtensions

I hope this helps.

Mark Minasi

share|improve this answer

Not sure on the code, but Securable seems to be able to do this.

share|improve this answer
Exactly like this application - but I need to do it in code. I have searched WMI query results high and low and could not find any property that seemed to be connected to HW virtualization –  Raj Rao May 13 '09 at 3:12

Check this link, as you can see there, maybe you should use WMI classes to get info. .NET framework has System.Management namespace to do that. Win32_processor class can give you all info you need about processor, because you can't access the cpu flags directly using win32_processor class, maybe you need to check the value of VirtualizationFirmwareEnabled

share|improve this answer

Your Answer


