gpt4 book ai didi

c++ - 'GetProcessIdOfThread' : identifier not found

转载 作者:太空狗 更新时间:2023-10-29 23:50:28 27 4
gpt4 key购买 nike

这是我在 stdafx.h 中的代码:

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#define _WIN32_WINNT 0x0502

#include "winsock2.h"
#include "windows.h"
#include "stdio.h"
#include "Iphlpapi.h"
#include <psapi.h>
#include "Ntsecapi.h"
#include "txdtc.h"
#include "xolehlp.h"
#include <iostream>
#include <tchar.h>

// TODO: reference additional headers your program requires here

如你所见,我已经包含了“windows.h”

这里是主要代码:

#include "stdafx.h"    
...
if (hThread && dwRpcssPid == GetProcessIdOfThread(hThread))
...

我的错误是:

'GetProcessIdOfThread': identifier not found

IntelliSense: identifier "GetProcessIdOfThread" is undefined

如何修复这些错误?

最佳答案

_WIN32_WINNT 值小于 0x0600 又名 _WIN32_WINNT_VISTA 时,该函数不可用。如果您以这种方式更改代码,您将使其正常工作:

//#define _WIN32_WINNT  0x0502
#define _WIN32_WINNT 0x0600

此函数从 Vista 开始可用,要针对 Vista+,您应该分别定义此值。

要使用当前 SDK 以最新版本的 API 为目标,您只需包含 SDKDDKVer.h 即可为您定义这些值/

//#define _WIN32_WINNT  0x0502
#include <SDKDDKVer.h>

另见:

关于c++ - 'GetProcessIdOfThread' : identifier not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30029140/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com