C++ TlHelp32.h 不工作?

标签 c++ header

虽然我不断收到消息,但我已正确包含 TlHelp32.h header :

"Error: identifier "CreateToolhelp32Snapshot" is undefined"

尝试使用 CreateToolhelp32Snapshot 时。当我在 VS 中使用“查看定义”功能时,我发现此 header 中的某些区域存在错误:

"Error expected a ';'"

有什么办法解决这个问题吗?

#include "stdafx.h"
#include <TlHelp32.h> 
#include <Windows.h>
#include <iostream>

using namespace std;

class Functions{

public:
    void playerHealthPrinter(){
        HANDLE hProcess;
        DWORD dwPID, dwProtection, dwCaveAddress;

        BOOL bPOn, bIOn, bProt;
        HANDLE hPID = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);

最佳答案

永远不要在 之前包含 Win32 header <windows.h> .以下应该起作用:

#include <Windows.h>
#include <TlHelp32.h> // <-- include *after* windows.h

如果还是不行,请发一个MCVE包括相关的 header 和 VS 版本。

关于C++ TlHelp32.h 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34502661/

相关文章:

c++ - 使用Visual Studio 2012的编译器为Windows XP制作Qt应用程序

c++ - 使用 `fork()` 反转字符串

object - aurelia-fetch-client 动态创建请求 header

c++ - 缺少类型说明符 - int 假定为 C4430 错误

javascript - 如何添加标题以形成 Angular 5中的数据

c++ - 如何将 C++ 变量存储为 NSDictionary 中的值?

c++ - 对于C++动态内存分配的确切含义有些困惑

c++ - 类似浮点函数的不同结果

header - liferay 中 header-portlet-javascript 的可配置值

php - MySQLi重定向问题