DWORD GetModuleFileName(hModule, lpszPath, cchPath) | |||||
HANDLE hModule; | /* identifies module to find filename for | */ | |||
LPTSTR lpszPath; | /* address of buffer for image file pathname | */ | |||
DWORD cchPath; | /* size of the buffer in characters | */ |
The GetModuleFileName function retrieves the full pathname for the executable file containing the specified module.
hModule
Identifies the module whose executable file name is being requested. If the parameter is NULL, GetModuleFileName returns the pathname for the file used to create the current process.
lpszPath
Points to a buffer for the pathname.
cchPath
Specifies the length of the path buffer (in characters). If the pathname is longer than cchPath, it is truncated.
If the function is successful, the return value specifies the actual length (in characters) of the string copied to the buffer.
If the function fails, the return value is zero. Use the GetLastError function to obtain extended error information.
The GetModuleFileName function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).