网站首页  词典首页

请输入您要查询的函数:

 

术语 getmodulebasename
释义 GetModuleBaseName
语法:
C++
DWORD WINAPI GetModuleBaseName(
__in HANDLE hProcess,
__in_opt HMODULE hModule,
__out LPTSTR lpBaseName,
__in DWORD nSize
);
GetModuleBaseName功能
检索指定模块的基本名称。
参数
hProcess [in]
句柄的进程,它包含的模块。
句柄必须有PROCESS_QUERY_INFORMATION和PROCESS_VM_READ访问权限。有关更多信息,请参见过程的安全性和访问权限。
hModule [中,可选]
句柄到模块。如果该参数为NULL,这个函数返回用于创建调用进程的文件名。
lpBaseName [out]
一个缓冲区,接收模块的基本名称的指针。如果基地名称超过由nSize参数指定最大字符数,基地名称被截断。
nSize [in]
该lpBaseName缓冲区的大小,以字符。
返回值
如果函数成功,返回值指定了复制到缓冲区的字符串的长度,以字符。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
该GetModuleBaseName功能主要是用来通过调试器和类似的应用程序必须提取从另一个进程模块信息的使用。如果在目标进程模块列表已损坏或尚未初始化,或者如果在作为结果的DLL函数调用模块列表的变化被加载或卸载,GetModuleBaseName可能失败或返回不正确的信息。
来检索在当前进程模块基地的名称,使用GetModuleFileName函数来检索全部模块的名称,然后使用一个函数调用,如strrchr(szmodulename,'\\ \\')扫描到基地内名称的开头模块名称字符串。这是更有效和更比调用的句柄当前进程GetModuleBaseName可靠。
以检索远程进程的可执行模块的主要基地的名称,使用GetProcessImageFileName或QueryFullProcessImageName函数来检索模块名称,然后使用strrchr函数,如前段所述。这是更有效和更比调用一个空模块句柄GetModuleBaseName可靠。
该GetModuleBaseName函数不检索那些与LOAD_LIBRARY_AS_DATAFILE标志加载的模块的基本名称。有关更多信息,请参阅LoadLibraryEx。
与PSAPI版本的Windows 7和Windows Server 2008 R2的2起,这个函数被定义为K32GetModuleBaseName在Psapi.h和Kernel32.lib和Kernel32.dll出口。但是,您应该始终作为GetModuleBaseName调用这个函数。为了确保对程序将运行在Windows的早期版本的符号的正确决议,添加Psapi.lib到TARGETLIBS宏和编译程序与- DPSAPI_VERSION = 1。
实例
有关示例,请参见枚举所有进程。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderPsapi.h
LibraryKernel32.lib在Windows 7和Windows Server 2008 R2的Psapi.lib在Windows Server 2008,Windows Vista中的Windows Server 2003,和Windows XP/2000
DLLKernel32.dll在Windows 7和Windows Server 2008 R2的Psapi.dll在Windows Server 2008,Windows Vista中的Windows Server 2003,和Windows XP/2000
Unicode和ANSI namesGetModuleBaseNameW(Unicode)和GetModuleBaseNameA(ANSI)的
参见
EnumProcesses
GetModuleFileNameEx
模块信息
PSAPI函数
strrchr,wcsrchr,_mbsrchr,_mbsrchr_l
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==GetModuleBaseName Function
Retrieves the base name of the specified module.
Syntax
C++
DWORD WINAPI GetModuleBaseName(
__in HANDLE hProcess,
__in_opt HMODULE hModule,
__out LPTSTR lpBaseName,
__in DWORD nSize
);
Parameters
hProcess [in]
A handle to the process that contains the module.
The handle must have the PROCESS_QUERY_INFORMATION and PROCESS_VM_READ access rights. For more information, see Process Security and Access Rights .
hModule [in, optional]
A handle to the module. If this parameter is NULL, this function returns the name of the file used to create the calling process.
lpBaseName [out]
A pointer to the buffer that receives the base name of the module. If the base name is longer than maximum number of characters specified by the nSize parameter, the base name is truncated.
nSize [in]
The size of the lpBaseName buffer, in characters.
Return Value
If the function succeeds, the return value specifies the length of the string copied to the buffer, in characters.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
Remarks
The GetModuleBaseName function is primarily designed for use by debuggers and similar applications that must extract module information from another process. If the module list in the target process is corrupted or is not yet initialized, or if the module list changes during the function call as a result of DLLs being loaded or unloaded, GetModuleBaseName may fail or return incorrect information.
To retrieve the base name of a module in the current process, use the GetModuleFileName function to retrieve the full module name and then use a function call such as strrchr(szmodulename, '\\\\') to scan to the beginning of the base name within the module name string. This is more efficient and more reliable than calling GetModuleBaseName with a handle to the current process.
To retrieve the base name of the main executable module for a remote process, use the GetProcessImageFileName or QueryFullProcessImageName function to retrieve the module name and then use the strrchr function as described in the previous paragraph. This is more efficient and more reliable than calling GetModuleBaseName with a NULL module handle.
The GetModuleBaseName function does not retrieve the base name for modules that were loaded with the LOAD_LIBRARY_AS_DATAFILE flag. For more information, see LoadLibraryEx .
Starting with PSAPI version 2 for Windows 7 and Windows Server 2008 R2, this function is defined as K32GetModuleBaseName in Psapi.h and exported in Kernel32.lib and Kernel32.dll. However, you should always call this function as GetModuleBaseName. To ensure correct resolution of symbols for programs that will run on earlier versions of Windows, add Psapi.lib to the TARGETLIBS macro and compile the program with –DPSAPI_VERSION=1.
Examples
For an example, see Enumerating All Processes .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderPsapi.h
LibraryKernel32.lib on Windows 7 and Windows Server 2008 R2, Psapi.lib on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP/2000
DLLKernel32.dll on Windows 7 and Windows Server 2008 R2, Psapi.dll on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP/2000
Unicode and ANSI namesGetModuleBaseNameW (Unicode) and GetModuleBaseNameA (ANSI)
See Also
EnumProcesses
GetModuleFileNameEx
Module Information
PSAPI Functions
strrchr, wcsrchr, _mbsrchr, _mbsrchr_l
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms683196(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:17:07