I think the title is self explanatory... I'm writing an application in C++ and I need to determine at runtime if I'm running under Wine (to change the bahavior a little in order to avoid a specific Wine bug). Is there a programmer-friendly way or should I fiddle with running processes?
Asked
Active
Viewed 5,444 times
27
-
11If you have found a bug in Wine, please make sure that you report it. – Šimon Tóth Sep 10 '11 at 14:32
-
2@Kerrek That is a compile time constant. – Šimon Tóth Sep 10 '11 at 14:33
-
Are you sure it's a Wine bug and not you relying on non-documented behavior of Windows? – Matteo Italia Sep 10 '11 at 14:38
-
No, I'm not, but that is unimportant. :) I know how to fix the problem, I just need to know if I'm running under Wine. I'll try with registry. – kingofx87 Sep 10 '11 at 15:25
-
4Better answer: http://www.winehq.org/pipermail/wine-devel/2008-September/069387.html See also http://wiki.winehq.org/DeveloperFaq#head-96551a33b168826cd805c2f62c4ea705ac02f350 – Jun 14 '12 at 18:43
2 Answers
16
This answer is just a copy of user1457056's comment. Since links often die, answers occasionally become useless. I have copied the link content here in order to preserve this useful answer:
#include <windows.h>
#include <stdio.h>
int main(void)
{
static const char *(CDECL *pwine_get_version)(void);
HMODULE hntdll = GetModuleHandle("ntdll.dll");
if(!hntdll)
{
puts("Not running on NT.");
return 1;
}
pwine_get_version = (void *)GetProcAddress(hntdll, "wine_get_version");
if(pwine_get_version)
{
printf("Running on Wine... %s\n",pwine_get_version());
}
else
{
puts("did not detect Wine.");
}
return 0;
}

Gabriel Ravier
- 358
- 1
- 6
- 17

Christoph Meißner
- 1,511
- 2
- 21
- 40
11
There are many Wine specific registry entries:
HKEY_CURRENT_USER\Software\Wine
HKEY_LOCAL_MACHINE\Software\Wine
Checking if a registry key exists has the answer of how to check for these Wine-specific registry keys.

Community
- 1
- 1

Šimon Tóth
- 35,456
- 20
- 106
- 151
-
2This is a bad solution, because anyone could create these registry keys on Windows as well. – Mario Jan 28 '23 at 10:22