繁体   English   中英

确定程序是否在运行时在Wine下运行

[英]Determine whether a program is running under Wine at runtime

我认为标题是自我解释的...我正在用C ++编写一个应用程序,我需要在运行时确定我是否在Wine下运行(为了避免特定的Wine bug而稍微更改行为)。 有程序员友好的方式还是我应该运行流程?

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

HKEY_CURRENT_USER\Software\Wine
HKEY_LOCAL_MACHINE\Software\Wine

检查是否存在注册表项具有如何检查这些特定于Wine的注册表项的答案。

这个答案只是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;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM