Created
January 12, 2018 05:54
-
-
Save klange/282e62fdd1c2cae6a210443ccbc5b12f to your computer and use it in GitHub Desktop.
wine detect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ wine ./winedetect.exe | |
Running Wine 1.8.7 under Linux 4.9.0-4-amd64. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
int main(int argc, char * argv[]) { | |
static const char * (CDECL *pwine_get_version)(void); | |
static void (CDECL *pwine_get_host_version)(const char **sysname, const char **release); | |
HMODULE hntdll = GetModuleHandle("ntdll.dll"); | |
if (!hntdll) { | |
fprintf(stdout, "Not running on NT.\n"); | |
return 1; | |
} | |
pwine_get_version = (void *)GetProcAddress(hntdll, "wine_get_version"); | |
pwine_get_host_version = (void *)GetProcAddress(hntdll, "wine_get_host_version"); | |
if (pwine_get_version) { | |
char * sysname; | |
char * version; | |
pwine_get_host_version(&sysname, &version); | |
fprintf(stdout, "Running Wine %s under %s %s.\n", pwine_get_version(), sysname, version); | |
} else { | |
fprintf(stdout, "Running under Windows.\n"); | |
return 2; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment