Many users now like to use virtual machines to test their software to avoid damage to the real machine environment. However, in the virtual machine, some features are limited, and even impossible to complete, so you need to determine the environment of the virtual machine in the program, if the program is running within the virtual machine, it will be the virtual machine can not be used under the function of the screen off.
To determine if the program is within a VMware virtual machine, you can do so using the following code:
function Isruninvmware (out errmsg:string): Boolean;
Begin
Result: = False;
Try
Asm
Push edx
Push ECX
Push EBX
mov eax, ' vmxh '
mov ecx, $0a
mov edx, ' VX '
in eax, DX
CMP ebx, ' vmxh '
Setz [Result]
Pop ebx
Pop ecx
Pop edx
End
Except
On E:exception do
ErrMsg: = E.message;
End
End
This code was compiled under Delphi2009, and the VMWare 5/6 test passed.
Determine if the program is running within VMware