【问题标题】:`DebugActiveProcessStop' undeclared (first use this function)`DebugActiveProcessStop' 未声明(首先使用此函数)
【发布时间】:2017-05-28 04:26:48
【问题描述】:

问题与this 相同,但是该解决方案对我不起作用。

根据DebugActiveProcessStop 函数文档,支持的最低客户端是Windows XP。我使用的是 Windows 7。

// #ifdef _WIN32_WINNT
// #undef _WIN32_WINNT
// #endif

#define NTDDI_VERSION 0x05010000
// #define _WIN32_WINNT 0x0502

#include <iostream>
#include <windows.h>

using namespace std;

class CppDBG
{
    ...
    public:
        BOOL detach (void);
        ...
};

...

BOOL CppDBG :: detach (void)
{
    if (DebugActiveProcessStop(pid)) {
        cout << "[+] Finished debugging. Exiting...";
        return true;
    }
    else {
        cout << "[-] Error" << endl;
        return false;
    }
}

int main()
{
    CppDBG dbg;
    ...
    dbg.detach();
    return 0;
}

【问题讨论】:

  • I am using Windows 7 - 那又怎样?无论您在哪个系统上编译代码,都是绝对的。仅重要的是您使用的 sdk 版本(并且完全在使用)。如果您使用 sdk - 只需搜索声明 DebugActiveProcessStop 的位置,它是否在条件块 (#if) 中并符合此条件

标签: c++ debugging winapi


【解决方案1】:

我猜你的 IDE 安装了旧版本的 Windows API。

您得到的错误是编译器错误,告诉您编译器不知道DebugActiveProcessStop 是什么。对于编译器,这可以是任何东西(例如变量、常量、...)。此错误与您的系统运行的 Windows 版本无关。

要解决此问题,请尝试从 Microsoft 下载 Windows SDK 并告诉您的编译器使用它(更改包含目录、库路径等)。这在很大程度上取决于您使用的 IDE。但互联网应该能提供足够的帮助。

【讨论】:

  • 如果你的编译器是 MinGW,很可能你正在使用一个古老的 MinGW,它没有在 Windows 2000 之后引入的任何 API。请获取 MinGW-w64;不断更新。
猜你喜欢
  • 1970-01-01
  • 2013-11-25
  • 2012-05-19
  • 2014-04-22
  • 2012-05-07
  • 2012-07-13
  • 2013-05-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多