[Wine] How to discover within my application if executed in Wine?
austinenglish at gmail.com
Fri Jan 16 12:36:07 CST 2009
On Fri, Jan 16, 2009 at 12:21 PM, zizzo81 <wineforum-user at winehq.org> wrote:
> I'm a Delphi (Windows) developer and I was trying to use Wine to execute my applications on Linux (actually using a Kubuntu 8.10)
> Most thing works great, but some don't.
> I was wondering if there's a way to discover if I'm under Windows or Linux just having a function like IsWine() that returns a boolean value. In this way I will be able to fix those small things that don't work and have my application running on both systems.
We discourage this. The best thing to do would be fix those bugs in
wine. Short of that, fix your application in a way that works on both,
not hacks for wine/windows depending on the implementation. Depending
on hacks for wine is bad practice, as if it's updated in the future,
or fixed, your app may break unexpectedly/weirdly. You know the code
for your app, so fixing wine is already easier. If you can't fix the
bug, file good bug reports (with test cases).
> I tryed checking for OS version, like I do on Windows but I get an empty response from Wine. I could take this as an answer (in such case the return value should be TRUE), but that isn't a professional way of getting information from the system.
> Does anyone know a call to system function that will return if I'm under Windows or Linux?
If you're still convinced you want to do this (again, discouraged). A
few ways to do it:
Check for wine specific registry entries.
Check environmental variables (I used this method for automated
testing with AutoHotKey, I doubt any windows machine has the 'SHELL'
environmental variable, unless running under cygwin, which wouldn't
work anyway ;-).)
Test for broken behavior, which may be viable if any windows version
Again, ways to do it (best to worst):
1) Fix properly in wine.
2) Adjust app in way that works in windows AND wine, sans hacks.
3) Detect wine, hack around it (BAD).
More information about the wine-users