Opening URL under Wine

note This article available in Russian.

Imagine the following situation. Our product can detect if it is running under WineHQ already. And, indeed, our product has many places from which we must open URL’s:

  • information about the product,
  • checking for updates,
  • online help,
  • technical support page
  • and so on.

Trying to call ShellExecute head-on, passing the URL as parameter, and … Nothing happens!

The thing is that Wine, honestly emulating everything, wants to start a web browser not installed in the system, but installed under the Wine. There are no any browsers installed yet. Therefore, nothing happens.

Of course, you can install the browser, but why not open the required documents in their native system applications? This raises the question of interaction of the Wine and the operating system.

There are a number of commands available in Wine.

We are interested in winebrowser command, which opens the URL in the native operating system application. And taking into account that URL can refer to the file, we have really serious mechanism in our hands.

winebrowser httр://


winebrowser irc://

winebrowser file://c:\\windows\\win.ini

On a KDE system the first two might open in Konqueror, the third in Konversation, and the last in KWrite.

As a result, applying the function GetWineAvail (), described earlier, our code might look like this:

//Delphi Code

procedure OpenUrl(url: string);
  S: string;
  if GetWineAvail() then 
    S := 'winebrowser ' + url
    S := url;
  ShellExecute(0, 'open', PChar(S), nil, nil, SW_SHOW);


or like this:

//C Code
void OpenUrl(char * url);
    char s[255];
    if (GetWineAvail())
        strcpy(s, "winebrowser ");
        strcat(s, url);
        strcpy(s, url);
    ShellExecute(NULL"open", s, NULLNULL, SW_SHOW);


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.