Kernel32GetModuleFileName Method
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.Auto, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
public static uint GetModuleFileName(
IntPtr hModule,
StringBuilder filename,
uint size
)
<DllImportAttribute("Kernel32.dll", CharSet := CharSet.Auto, BestFitMapping := false,
ThrowOnUnmappableChar := true, SetLastError := true>]
Public Shared Function GetModuleFileName (
hModule As IntPtr,
filename As StringBuilder,
size As UInteger
) As UInteger
Dim hModule As IntPtr
Dim filename As StringBuilder
Dim size As UInteger
Dim returnValue As UInteger
returnValue = Kernel32.GetModuleFileName(hModule,
filename, size)
public:
[DllImportAttribute(L"Kernel32.dll", CharSet = CharSet::Auto, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
static unsigned int GetModuleFileName(
IntPtr hModule,
StringBuilder^ filename,
unsigned int size
)
[<DllImportAttribute("Kernel32.dll", CharSet = CharSet.Auto, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)>]
static member GetModuleFileName :
hModule : IntPtr *
filename : StringBuilder *
size : uint32 -> uint32
No code example is currently available or this language may not be supported.
- hModule IntPtr
-
A handle to the loaded module whose path is being requested.
If this parameter is ,
GetModuleFileName(IntPtr, StringBuilder, UInt32) retrieves the path of the executable file of the current process.
The GetModuleFileName(IntPtr, StringBuilder, UInt32) function does not retrieve the path for
modules that were loaded using the LoadLibraryAsDataFile flag.
- filename StringBuilder
-
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 size parameter specifies,
the function succeeds and the path is returned as a null-terminated string.
- size UInt32
-
The size of the filename buffer.
UInt32
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
size characters
including the terminating null character, the function returns
size,
and the function sets the last error to
ERROR_INSUFFICIENT_BUFFER.
If
size is zero, the return value is 0 (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
GetLastWin32Error.