On Wine or not on Wine?

note 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;
 Result := False;
 H := LoadLibrary('ntdll.dll');
   Result := Assigned(GetProcAddress(H, 'wine_get_version'));

if GetWineAvail() then 
 ShowMessage('Launched under Wine')
 ShowMessage('Pure Windows');

Сode speaks for itself.

4 thoughts on “On Wine or not on Wine?

  1. 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.


  2. Pingback: Opening URL under Wine « Pasha Golub's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s