Under Wine or not under Wine?
In the life of every Windows developer, there may come a time when blood from the nose needs to understand whether WineHQ is running the program or not. Why? Because the world is not perfect, and it is necessary to help Wine digest the application correctly. Of course, if the developer cares about the feedback from the guys on the other side of the barricades (Mac, Linux, etc.).
I will name a few reasons why our team needed it :
- CHM helpers are disgustingly displayed under Wine;
- on bare Wine there are no MS Jet 4.0 and MS MDAC 2.8;
- and as it turned out, our applications ( one and two ) look better when using Microsoft Core Fonts (Arial, Courier, Times, etc.).
I am sure the list can be supplemented, but this is not the purpose of this article.
The method is elegant and simple. I believe that any sane developer will be able to adapt this for their favorite language.
Implementation for C:
bool GetWineAvail ()
HMODULE h = LoadLibrary ("ntdll.dll");
bool r = false;
if (h! = NULL)
r = GetProcAddress (h, "wine_get_version")! = NULL;
if (GetWineAvail ())
ShowMessage ("Wine around, cap!");
ShowMessage ("I did not see the windows more transparently.");
Implementation for Delphi:
function GetWineAvail: boolean;
var H: cardinal;
Result: = False ;
H: = LoadLibrary ('ntdll.dll');
if H> 0 then
Result: = Assigned (GetProcAddress (H, 'wine_get_version'));
if GetWineAvail () then
ShowMessage ('Hooray! We are under Winish!')
ShowMessage ('Pure Windows, sir!');