Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine whether a program is running under Wine at runtime

Tags:

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?

like image 540
kingofx87 Avatar asked Sep 10 '11 14:09

kingofx87


2 Answers

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; } 
like image 134
Christoph Meißner Avatar answered Sep 19 '22 00:09

Christoph Meißner


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.

like image 31
Šimon Tóth Avatar answered Sep 23 '22 00:09

Šimon Tóth