网站首页  词典首页

请输入您要查询的函数:

 

术语 getmodulehandleex
释义 GetModuleHandleEx
语法:
C++
BOOL WINAPI GetModuleHandleEx(
__in DWORD dwFlags,
__in_opt LPCTSTR lpModuleName,
__out HMODULE *phModule
);
GetModuleHandleEx功能
检索模块句柄指定的模块。该模块必须是加载调用进程。
参数
dwFlags [in]
此参数可以是一个或多个下列值。
ValueMeaning
0Increment引用计数。这是默认情况。
调用者必须使用FreeLibrary函数时,使用完的模块句柄。
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
0x00000004The lpModuleName参数是在模块的地址。
GET_MODULE_HANDLE_EX_FLAG_PIN
0x00000001The模块保持加载,直到该进程终止时,没有多少次FreeLibrary被称为问题。
此选项不能用于GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT。
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
0x00000002Do没有增量模块的引用计数。此选项相当于GetModuleHandle行为。
This option cannot be used with GET_MODULE_HANDLE_EX_FLAG_PIN.
lpModuleName [中,可选]
加载的模块的名称(无论是。dll或。exe文件),或对一个地址指针模块(如果dwFlags是GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS)。
对于一个模块名,如果文件扩展名被省略,默认的库扩展的。dll追加。该文件名字符串可以包含一个尾随点字符(。)表明,模块的名称没有扩展名。该字符串没有指定路径。当指定的路径,一定要使用反斜杠(\\),而不是正斜杠(/)。这个名字是比较(下独立),以目前的模块将调用进程的地址空间映射名称。
如果该参数为NULL,则函数返回的句柄用于创建调用进程(。exe文件)的文件。
phModule [out]
一个句柄,指定的模块。如果函数失败,这个参数是NULL。
该GetModuleHandleEx功能不检索处理该被装用LOAD_LIBRARY_AS_DATAFILE标志模块。有关更多信息,请参阅LoadLibraryEx。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,请参考GetLastError函数。
备注
返回句柄不是全球或继承。它不能被复制或由另一个进程使用。
如果lpModuleName不包括道路,有多个具有相同的基本名称和扩展加载的模块,您无法预测的模块句柄将返回。若要解决此问题,您可以指定一个路径,请使用侧的并行程序集,或指定一个内存位置,而不是在lpModuleName参数的DLL名称。
如果dwFlags包含GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,请务必小心路过时的句柄FreeLibrary函数,因为这样做可能导致DLL模块被映射过早。
如果dwFlags包含GET_MODULE_HANDLE_EX_UNCHANGED_REFCOUNT,这个函数必须小心使用,在多线程应用程序。没有任何保证模块句柄仍然有效,这之间的时间函数返回的句柄和它的使用时间。例如,一个线程检索模块句柄,但在它使用的处理,第二个线程释放模块。如果系统负载另一个模块,它可以重复使用的模块句柄最近获释。因此,第一个线程将有一个模块句柄一个比预期的不同。
要编译的应用程序使用此功能,定义_WIN32_WINNT为0x0501或更高版本。有关详细信息,请参阅使用Windows头。
要求:
最低支持client-Windows XP
最低支持serverWindows服务器2003
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesGetModuleHandleExW(Unicode)和GetModuleHandleExA(ANSI)的
参见
动态链接库函数
FreeLibrary
GetModuleFileName
调用LoadLibrary
LoadLibraryEx
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==GetModuleHandleEx Function
Retrieves a module handle for the specified module. The module must have been loaded by the calling process.
Syntax
C++
BOOL WINAPI GetModuleHandleEx(
__in DWORD dwFlags,
__in_opt LPCTSTR lpModuleName,
__out HMODULE *phModule
);
Parameters
dwFlags [in]
This parameter can be one or more of the following values.
ValueMeaning
0Increment the reference count. This is the default case.
The caller must use the FreeLibrary function when they have finished using the module handle.
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
0x00000004The lpModuleName parameter is an address in the module.
GET_MODULE_HANDLE_EX_FLAG_PIN
0x00000001The module stays loaded until the process is terminated, no matter how many times FreeLibrary is called.
This option cannot be used with GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT.
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT
0x00000002Do not increment the reference count for the module. This option is equivalent to the behavior of GetModuleHandle .
This option cannot be used with GET_MODULE_HANDLE_EX_FLAG_PIN.

lpModuleName [in, optional]
The name of the loaded module (either a .dll or .exe file), or a pointer to an address in the module (if dwFlags is GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS).
For a module name, if the file name extension is omitted, the default library extension .dll is appended. The file name string can include a trailing point character (.) to indicate that the module name has no extension. The string does not have to specify a path. When specifying a path, be sure to use backslashes (\\), not forward slashes (/). The name is compared (case independently) to the names of modules currently mapped into the address space of the calling process.
If this parameter is NULL, the function returns a handle to the file used to create the calling process (.exe file).
phModule [out]
A handle to the specified module. If the function fails, this parameter is NULL.
The GetModuleHandleEx function does not retrieve handles for modules that were loaded using the LOAD_LIBRARY_AS_DATAFILE flag. For more information, see LoadLibraryEx .
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, see GetLastError .
Remarks
The handle returned is not global or inheritable. It cannot be duplicated or used by another process.
If lpModuleName does not include a path and there is more than one loaded module with the same base name and extension, you cannot predict which module handle will be returned. To work around this problem, you could specify a path, use side-by-side assemblies , or specify a memory location rather than a DLL name in the lpModuleName parameter.
If dwFlags contains GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, use care when passing the handle to the FreeLibrary function, because doing so can cause a DLL module to be unmapped prematurely.
If dwFlags contains GET_MODULE_HANDLE_EX_UNCHANGED_REFCOUNT, this function must be used carefully in a multithreaded application. There is no guarantee that the module handle remains valid between the time this function returns the handle and the time it is used. For example, a thread retrieves a module handle, but before it uses the handle, a second thread frees the module. If the system loads another module, it could reuse the module handle that was recently freed. Therefore, first thread would have a handle to a module different than the one intended.
To compile an application that uses this function, define _WIN32_WINNT as 0x0501 or later. For more information, see Using the Windows Headers .
Requirements
Minimum supported clientWindows XP
Minimum supported serverWindows Server 2003
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesGetModuleHandleExW (Unicode) and GetModuleHandleExA (ANSI)
See Also
Dynamic-Link Library Functions
FreeLibrary
GetModuleFileName
LoadLibrary
LoadLibraryEx
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms683200(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 11:28:02