GetModuleBaseName

From aldeid
Jump to navigation Jump to search

Description

Retrieves the base name of the specified module.

Syntax

DWORD WINAPI GetModuleBaseName(
  _In_      HANDLE hProcess,
  _In_opt_  HMODULE hModule,
  _Out_     LPTSTR lpBaseName,
  _In_      DWORD nSize
);

Parameters

hProcess [in]
A handle to the process that contains the module.
The handle must have the PROCESS_QUERY_INFORMATION and PROCESS_VM_READ access rights.
hModule [in, optional]
A handle to the module. If this parameter is NULL, this function returns the name of the file used to create the calling process.
lpBaseName [out]
A pointer to the buffer that receives the base name of the module. If the base name is longer than maximum number of characters specified by the nSize parameter, the base name is truncated.
nSize [in]
The size of the lpBaseName buffer, in characters.

Return value

If the function succeeds, the return value specifies the length of the string copied to the buffer, in characters.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

DLL

  • Kernel32.dll on Windows 7 and Windows Server 2008 R2;
  • Psapi.dll (if PSAPI_VERSION=1) on Windows 7 and Windows Server 2008 R2;
  • Psapi.dll on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP