Kernel32GetModuleHandle Method
Retrieves a module handle for the specified module.
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 IntPtr GetModuleHandle(
[OptionalAttribute] string moduleName
)
<DllImportAttribute("Kernel32.dll", CharSet := CharSet.Ansi, BestFitMapping := false,
ThrowOnUnmappableChar := true, SetLastError := true>]
Public Shared Function GetModuleHandle (
<OptionalAttribute> moduleName As String
) As IntPtr
Dim moduleName As String
Dim returnValue As IntPtr
returnValue = Kernel32.GetModuleHandle(moduleName)
public:
[DllImportAttribute(L"Kernel32.dll", CharSet = CharSet::Ansi, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
static IntPtr GetModuleHandle(
[OptionalAttribute] String^ moduleName
)
[<DllImportAttribute("Kernel32.dll", CharSet = CharSet.Ansi, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)>]
static member GetModuleHandle :
[<OptionalAttribute>] moduleName : string -> IntPtr
No code example is currently available or this language may not be supported.
- moduleName String (Optional)
-
The name of the loaded module (either a .dll or .exe file).
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).
IntPtr
If the function succeeds, the return value is a handle to the specified module.
If the function fails, the return value is
Zero.
To get extended error information, call
GetLastWin32Error.