'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” 未定义
我怎样才能解决这些错误?
答
该功能不适用于_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>
参见:
答
GetProcessIdOfThread
的平台要求规定:
Windows Vista中[桌面应用程序仅] [只有桌面应用程序]
Windows Server 2003的
和标题的要求规定:
Windows 8和Windows上的Processthreadsapi.h Server 2012中
所以:
- 确保Windows SDK达最新
- 确保您指定的platform requirements properly。
- 确保你包含正确的头文件。
难道只是* *智能感知错误?如果是这样,那么你可以忽略它。除此之外,你不会在'stdafx.h'的同一目录下有一个名为'windows.h'的文件,是吗?或者,是否在'GetProcessIdOfThread()'的相同文件*中添加'#include'去除错误? –
Biffen
很抱歉,请查看我的问题。 – MoonLight