c++ - 'GetProcessIdOfThread' : identifier not found

标签 c++ winapi visual-studio-2013 windows-7

这是我在 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/

相关文章:

c++ - 不退出怎么处理空指针?

c# - Visual Studio Express 2013 : Program output in unit tests (console, 调试等)

iis - Web.config 大小限制错误

c++ - 使用 std::map::at 时出错

c++ - 从方法参数推断模板

winapi - 在发布版本中获取调用堆栈时出现问题

c++ - 应用程序重新启动,提升 "runas",在 ITaskbarList 使用之前不捕获 TaskbarButtonCreated Msg?

javascript - 如何禁用 Windows Phone 键盘?

c++ - 异步读取文件 - iso 文件 C++

java - Java 端未找到我的 native 方法