网站首页  词典首页

请输入您要查询的函数:

 

术语 getmodulefilename
释义 GetModuleFileName
语法:
C++
DWORD WINAPI GetModuleFileName(
__in_opt HMODULE hModule,
__out LPTSTR lpFilename,
__in DWORD nSize
);
GetModuleFileName函数
检索完全限定路径的文件,其中包含指定的模块。该模块被加载必须由当前的进程。
要找到一个被另一个进程加载的模块,使用GetModuleFileNameEx函数文件。
参数
hModule [中,可选]
一个句柄,加载的模块的路径正在请求。如果该参数为NULL,GetModuleFileName检索当前进程的可执行文件的路径。
该GetModuleFileName函数不检索该被装用LOAD_LIBRARY_AS_DATAFILE标志模块路径。有关更多信息,请参阅LoadLibraryEx。
lpFilename [out]
阿一个缓冲区,它接收的完全合格的路径模块的指针。如果路径长度小于大小的nSize参数指定,则该函数成功的路径返回一个NULL结尾的字符串。
如果路径的长度超过了大小的nSize参数指定函数成功和字符串被截断为nSize包括终止空字符的字符。
Windows XP/2000操作系统:该字符串被截断为nSize字符,而不是空终止。
返回的字符串将使用相同的格式时指定的模块被加载。因此,路径可以是长或短文件名,并可以使用前缀“\\ \\?\\”。有关更多信息,请参见命名一个文件。
nSize [in]
该lpFilename缓冲区的大小,在TCHARs。
返回值
如果函数成功,返回值是被复制到缓冲区字符串字符,长度,不包括终止空字符。如果缓冲区太小,不能容纳的模块名称,字符串被截断为nSize包括终止空字符,则函数返回nSize字符,功能设置最后一个错误的ERROR_INSUFFICIENT_BUFFER。
Windows XP/2000操作系统:如果缓冲区太小,不能容纳的模块名称,该函数返回nSize。最后一个错误代码仍然ERROR_SUCCESS。如果nSize为零,则返回值为0,最后一个错误代码是ERROR_SUCCESS。
如果函数失败,返回值为0(零)。为了获得更多错误信息,调用GetLastError。
备注
如果DLL是装在两个进程,其进程中的一个文件名可能有所不同,其文件名中的其他进程的情况。
全局变量_pgmptr自动初始化为可执行文件的完整路径,可用于检索一个可执行文件的完整路径名。
实例
有关示例,请参见安装服务。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesGetModuleFileNameW(Unicode)和GetModuleFileNameA(ANSI)的
参见
动态链接库函数
GetModuleFileNameEx
GetModuleHandle
调用LoadLibrary
LoadLibraryEx
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==GetModuleFileName Function
Retrieves the fully-qualified path for the file that contains the specified module. The module must have been loaded by the current process.
To locate the file for a module that was loaded by another process, use the GetModuleFileNameEx function.
Syntax
C++
DWORD WINAPI GetModuleFileName(
__in_opt HMODULE hModule,
__out LPTSTR lpFilename,
__in DWORD nSize
);
Parameters
hModule [in, optional]
A handle to the loaded module whose path is being requested. If this parameter is NULL, GetModuleFileName retrieves the path of the executable file of the current process.
The GetModuleFileName function does not retrieve the path for modules that were loaded using the LOAD_LIBRARY_AS_DATAFILE flag. For more information, see LoadLibraryEx .
lpFilename [out]
A pointer to a buffer that receives the fully-qualified path of the module. If the length of the path is less than the size that the nSize parameter specifies, the function succeeds and the path is returned as a null-terminated string.
If the length of the path exceeds the size that the nSize parameter specifies, the function succeeds and the string is truncated to nSize characters including the terminating null character.
Windows XP/2000: The string is truncated to nSize characters and is not null terminated.
The string returned will use the same format that was specified when the module was loaded. Therefore, the path can be a long or short file name, and can use the prefix "\\\\?\\". For more information, see Naming a File .
nSize [in]
The size of the lpFilename buffer, in TCHARs.
Return Value
If the function succeeds, the return value is the length of the string that is copied to the buffer, in characters, not including the terminating null character. If the buffer is too small to hold the module name, the string is truncated to nSize characters including the terminating null character, the function returns nSize, and the function sets the last error to ERROR_INSUFFICIENT_BUFFER.
Windows XP/2000: If the buffer is too small to hold the module name, the function returns nSize. The last error code remains ERROR_SUCCESS. If nSize is zero, the return value is zero and the last error code is ERROR_SUCCESS.
If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError .
Remarks
If a DLL is loaded in two processes, its file name in one process may differ in case from its file name in the other process.
The global variable _pgmptr is automatically initialized to the full path of the executable file, and can be used to retrieve the full path name of an executable file.
Examples
For an example, see Installing a Service .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesGetModuleFileNameW (Unicode) and GetModuleFileNameA (ANSI)
See Also
Dynamic-Link Library Functions
GetModuleFileNameEx
GetModuleHandle
LoadLibrary
LoadLibraryEx
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms683197(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:15:31