词条 | GetModuleInformation |
释义 | 概述GetModuleInformation 函数 获取模块信息并储存在 MODULEINFO 结构。 语法 SyntaxBOOL WINAPI GetModuleInformation( __in HANDLE hProcess, __in HMODULE hModule, __out LPMODULEINFO lpmodinfo, __in DWORD cb ); 参数说明 ParameterhProcess 指向包含模块的进程的句柄。这个句柄一定要有 PROCESS_QUERY_INFORMATION 和 PROCESS_VM_READ 权限。参考 Process Security and Access Rights hModule 指向模块的句柄。 lpmodinfo 指向 MODULEINFO 结构的指针,该结构将会储存关于模块的信息。 cb 结构 MODULEINFO 的大小(以字节计算)。 返回值 Return Value如果函数成功,将返回非零数值 如果函数失败,将会返回 0 。调用 GetLastError 可得进一步信息。 附注 Remark要得到调用进程(即当前进程)的信息,可把 GetCurrentProcess返回值传给 hProcess。 对于加载时被设置 LOAD_LIBRARY_AS_DATAFILE 标志的模块,该函数不会返回信息。更多信息参考 LoadLibraryEx。 从 Window7 和 Windows Server 2008 R2 开始,Psapi.h 为 PSAPI 函数建立版本号。版本号会影响调用函数的名字和程序要加载的库。(原文: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.) 如果 PSAPI_VERSION 是 2 或者更高,该函数将会在 Psapi.h 定义为 K32GetModuleInformation 并且由 Kernel32.lib 和 Kernel32.dll 导出。如果 PSAPI_VERSION 是 1,该函数被定义为 GetModuleInformation 并且由 Psapi.lib 和 Psapi.dll 封装处理来调用 K32GetModuleInformation。(原文:If PSAPI_VERSION is 2 or greater, this function is defined as K32GetModuleInformation in Psapi.h and exported in Kernel32.lib and Kernel32.dll. If PSAPI_VERSION is 1, this function is defined as GetModuleInformation in Psapi.h and exported in Psapi.lib and Psapi.dll as a wrapper that calls K32GetModuleInformation.) 那些要运行在所有 Windows 版本的程序应该始终用 GetModuleInformation 名字来调用。为了确保名字正确,添加 Psapi.lib 到 TARGETLIBS macro(我不太清楚这东西,应该是说要引用 Psapi.lib)和用 –DPSAPI_VERSION=1 来编译程序。要动态加载动态链接库的要加载 Psapi.dll。(原文:Programs that must run on earlier versions of Windows as well as Windows 7 and later versions should always call this function as GetModuleInformation. 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.) 要求 Requirement客户端最低版本 Windows 2000 专业版/Windows 2000 Professional 服务器最低版本 Windows 2000 Server 头文件 Psapi.h 库/Library Window 7 和 Windows Server 2008 R2 下:Kernel32.lib 和 Psapi.lib(如果 PSAPI_VERSION=1 ) 动态链接库/DLL Window 7 和 Windows Server 2008 R2 下:Kernel32.dll 和 Psapi.dll(如果 PSAPI_VERSION=1 ) |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。