Test If Running Under Wine

Mike McCormack mike at codeweavers.com
Mon Oct 10 02:37:42 CDT 2005

Craig macLeod wrote:

> I am a developer of Win32 applications. We have recently found the 
> command ShellExecute when trying to browse folders functions differently 
> between Wine and Windows. This is mainly because there is no 
> implementation of Windows Explorer unider Wine so the command does nothing.
> How in our code do we differentiate between Wine runs and Windows runs?

You could test for the presence of HKCU\Software\Wine\Wine, but that 
might change later.

> The documentation discourages such tests saying we should fix Wine.
> My boss wants to do minimal changes to our code so how do we do a simple 
> test if we are using Wine or not? I have some code to test for the 
> existance of explore.exe and if not present then assume we are under 
> Linux. Is this sufficiently generic? (foreign languages etc)

It's discouraged because we might change the way things are done later, 
implement and explorer, etc and because we don't want applications to 
expect brokenness by default.  If somebody implements an explorer.exe 
that works in a few months, then your app will have permanently crippled 
itself, even though it might otherwise work.

Why not just run the ShellExecute and let it fail?


More information about the wine-devel mailing list