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.
Awesome!
Have a Delphi app that is OK under windows (95 to Vista), but under Wine, blinking in HTML component makes parts of text show for a split second, then disappear behind black rectangle. For the time being, now detect Wine and turn blinking off. Thanks heaps for the function.
LikeLike
You’re welcome. Have one more trick for Wine, but have no time to publish it 🙂
LikeLike
Thank you for wine check function. It is working perfectly under Lazarus.
LikeLike