Search code examples
delphidelphi-10.2-tokyo

how do i stop my app from running on Virtualbox?


I have tried this unit to detect if my application is running in Oracle VirtualBox, but it is not detecting VirtualBox.

I have tested it with Windows 7 installed in VirtualBox.

Is there any efficient way to prevent my VCL application from running in VirtualBox?


Solution

  • You can use The Win32_BaseBoard WMI class and check if the Product string contains the word "Virtual"

    For example :

    function _IsOSVirtual(): Boolean;
    const
      v = 'virtual';
    Begin
      Result := False;
      CoInitialize(nil);
      try
         if Pos(v, LowerCase(GetWin32_BaseBoard('Product'))) > 0 then
          Result := True;
      finally
        CoUninitialize;
      end;
    end;