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.
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:
procedure OpenUrl(url: string);
if GetWineAvail() then
S := 'winebrowser ' + url
S := url;
ShellExecute(0, 'open', PChar(S), nil, nil, SW_SHOW);
or like this:
void OpenUrl(char * url);
strcpy(s, "winebrowser ");
ShellExecute(NULL, "open", s, NULL, NULL, SW_SHOW);