虽然我不断收到消息,但我已正确包含 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/