'GetProcessIdOfThread':标识符找不到

'GetProcessIdOfThread':标识符找不到

问题描述:

这是我在stdafx.h中代码:'GetProcessIdOfThread':标识符找不到

// 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':标识符找不到

智能感知:标识符 “GetProcessIdOfThread” 未定义

我怎样才能解决这些错误?

+1

难道只是* *智能感知错误?如果是这样,那么你可以忽略它。除此之外,你不会在'stdafx.h'的同一目录下有一个名为'windows.h'的文件,是吗?或者,是否在'GetProcessIdOfThread()'的相同文件*中添加'#include '去除错误? – Biffen

+0

很抱歉,请查看我的问题。 – MoonLight

该功能不适用于_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> 

参见:

+0

感谢所有的答案,但是这个解决了我的问题。 – MoonLight

+0

R我如何与你聊天? – MoonLight

+0

@MoonLight:没有聊天,但您可以在我的个人资料的网站上找到电子邮件地址。 –

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

看到标题部分MSDN引用。

+0

我正在使用Windows 7 - 我已经添加了这一行:#include“Processthreadsapi.h”,但该错误仍然存​​在! – MoonLight

+0

hThread的类型是什么?它是一个std ::线程? – MaxVerro

+0

HANDLE hThread = OpenThread(THREAD_ALL_ACCESS,TRUE,Tid); – MoonLight

GetProcessIdOfThread的平台要求规定:

Windows Vista中[桌面应用程序仅] [只有桌面应用程序]

Windows Server 2003的

和标题的要求规定:

Windows 8和Windows上的Processthreadsapi.h Server 2012中

所以:

  1. 确保Windows SDK达最新
  2. 确保您指定的platform requirements properly
  3. 确保你包含正确的头文件。