【问题标题】:Determine whether a program is running under Wine at runtime运行时判断程序是否在Wine下运行
【发布时间】:2011-11-14 09:39:47
【问题描述】:

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

【问题讨论】:

  • 如果您发现 Wine 中的错误,请务必报告。
  • @Kerrek 这是一个编译时间常数。
  • 您确定这是一个 Wine 错误,而不是您依赖于 Windows 的未记录行为吗?
  • 不,我不是,但这并不重要。 :) 我知道如何解决这个问题,我只需要知道我是否在 Wine 下运行。我会尝试使用注册表。

标签: c++ wine


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    HKEY_CURRENT_USER\Software\Wine
    HKEY_LOCAL_MACHINE\Software\Wine
    

    Checking if a registry key exists 提供了如何检查这些 Wine 特定注册表项的答案。

    【讨论】:

      猜你喜欢
      • 2016-10-04
      • 2019-09-21
      • 2012-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多