Kernel32GetModuleHandleEx Method
Retrieves a module handle for the specified module and increments the module's reference count
unless
UnchangedReferenceCount flag is specified.
The module must have been loaded by the calling process.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", CharSet = CharSet.Ansi, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
public static bool GetModuleHandleEx(
GetModuleHandleExFlags flags,
[OptionalAttribute] string moduleName,
out IntPtr refModule
)
<DllImportAttribute("Kernel32.dll", CharSet := CharSet.Ansi, BestFitMapping := false,
ThrowOnUnmappableChar := true, SetLastError := true>]
Public Shared Function GetModuleHandleEx (
flags As GetModuleHandleExFlags,
<OptionalAttribute> moduleName As String,
<OutAttribute> ByRef refModule As IntPtr
) As Boolean
Dim flags As GetModuleHandleExFlags
Dim moduleName As String
Dim refModule As IntPtr
Dim returnValue As Boolean
returnValue = Kernel32.GetModuleHandleEx(flags,
moduleName, refModule)
public:
[DllImportAttribute(L"Kernel32.dll", CharSet = CharSet::Ansi, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
static bool GetModuleHandleEx(
GetModuleHandleExFlags flags,
[OptionalAttribute] String^ moduleName,
[OutAttribute] IntPtr% refModule
)
[<DllImportAttribute("Kernel32.dll", CharSet = CharSet.Ansi, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)>]
static member GetModuleHandleEx :
flags : GetModuleHandleExFlags *
[<OptionalAttribute>] moduleName : string *
refModule : IntPtr byref -> bool
No code example is currently available or this language may not be supported.
- flags GetModuleHandleExFlags
-
Flags that determines the load behavior.
If the module's reference count is incremented,
the caller must use the FreeLibrary(SafeModuleHandle) function to decrement the reference count when the
module handle is no longer needed.
- moduleName String (Optional)
-
The name Of the loaded Module (either a .dll Or .exe file),
Or an address In the Module (If flags Is FromAddress).
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 ,
the Function returns a handle To the file used To create the calling process (.exe file).
- refModule IntPtr
-
A handle to the specified module. If the function fails, this parameter is Zero.
The GetModuleHandleEx(GetModuleHandleExFlags, String, IntPtr) function does not retrieve handles for
modules that were loaded using the LoadLibraryAsDataFile flag.
Boolean
If the function succeeds, the return value is
.
If the function fails, the return value is
.
To get extended error information, call
GetLastWin32Error.