24

我认为标题是不言自明的......我正在用 C++ 编写一个应用程序,我需要在运行时确定我是否在 Wine 下运行(稍微改变一下行为以避免特定的 Wine 错误)。是否有程序员友好的方式或者我应该摆弄正在运行的进程?

4

2 回答 2

12

此答案只是 user1457056 评论的副本。由于链接经常失效,因此答案有时会变得无用。我在这里复制了链接内容以保留这个有用的答案:

#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;
}
于 2017-02-19T21:42:44.537 回答
11

有许多 Wine 特定的注册表项:

HKEY_CURRENT_USER\Software\Wine
HKEY_LOCAL_MACHINE\Software\Wine

检查注册表项是否存在可以回答如何检查这些 Wine 特定的注册表项。

于 2011-09-10T14:37:12.430 回答