"GetProcessIdOfThread":找不到标识符

'GetProcessIdOfThread': identifier not found

本文关键字:标识符 找不到 GetProcessIdOfThread      更新时间:2023-10-16

这是我的代码 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':找不到标识符

IntelliSense:标识符" getProcessIdofThread"是未定义的

如何解决这些错误?

_WIN32_WINNT值小于 0x0600 aka _WIN32_WINNT_VISTA,该功能不可用。如果您以这种方式更改代码,则可以使其正常工作:

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

该功能可用,因为Vista以来,要定位此值,您应该分别定义此值。

针对具有当前SDK的最新版本的API,您可以简单地包含sdkddkver.h,这些值将为您定义/

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

另请参见:

  • 什么是_WIN32_WINNT,它如何工作?

GetProcessIdOfThread的平台要求状态:

Windows Vista [仅桌面应用]

Windows Server 2003 [仅桌面应用]

和标题要求指出:

Windows 8和Windows Server 2012上的ProcessThreadSapi.h

so:

  1. 确保您的Windows SDK是最新的
  2. 确保您已正确指定了平台要求。
  3. 确保您包括正确的标题文件。

如果您使用的是Windows 8,则需要包括:ProcessThreadSapi.h

请参阅标题部分中的MSDN引用。