首页 > 代码库 > 无法定位程序输入点 K32GetProcessMemoryInfo于动态链接库kernel32.dll之上
无法定位程序输入点 K32GetProcessMemoryInfo于动态链接库kernel32.dll之上
这是由于GetProcessMemoryInfo在不同系统版本号不同导致的,官方说明如下:
Remarks
Starting with Windows 7 and Windows Server 2008 R2, Psapi.h establishes version numbers for the PSAPI functions. The PSAPI version number affects the name used to call the function and the library that a program must load.
If PSAPI_VERSION is 2 or greater, this function is defined as K32GetProcessMemoryInfo in Psapi.h and exported in Kernel32.lib and Kernel32.dll. If PSAPI_VERSION is 1, this function is defined as GetProcessMemoryInfo in Psapi.h and exported in Psapi.lib and Psapi.dll as a wrapper that calls K32GetProcessMemoryInfo.
Programs that must run on earlier versions of Windows as well as Windows 7 and later versions should always call this function as GetProcessMemoryInfo. To ensure correct resolution of symbols, add Psapi.lib to the TARGETLIBS macro and compile the program with -DPSAPI_VERSION=1. To use run-time dynamic linking, load Psapi.dll.
解决方案:
只需要在#include <psapi.h>引用前添加
#ifndef PSAPI_VERSION
#define PSAPI_VERSION 1
#endif
#include <psapi.h>
#pragma comment(lib,"Psapi.lib")
无法定位程序输入点 K32GetProcessMemoryInfo于动态链接库kernel32.dll之上