|This article available in Russian.|
In the life of every Windows developer there comes a point when you want to know if your application is running under WineHQ or not. Why? Because the world is not perfect. And you for sure will help Wine to crunch your application correctly. Of course if you’re interested in support of millions of guys with red eyes (Mac, Linux etc.).😉
There is an elegant way to find this out. Below is the Pascal\Delphi code, however any sane developer would be able to translate it into preferred language:
function GetWineAvail: boolean; var H: cardinal; begin Result := False; H := LoadLibrary('ntdll.dll'); if H > HINSTANCE_ERROR then begin Result := Assigned(GetProcAddress(H, 'wine_get_version')); FreeLibrary(H); end; end; //using if GetWineAvail() then ShowMessage('Launched under Wine') else ShowMessage('Pure Windows'); end;
Сode speaks for itself.