|
GetProcessImageFileName |
|
Description
Retrieves the name of the executable file for the specified process.
C++ Syntax
PowerBASIC Syntax
Unicode version:
Parameters
hProcess
[in] A handle to the process. The handle must have the PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION access right.
lpImageFileName
[out] A pointer to a buffer that receives the full path to the executable file.
cb
[in] The size of the lpImageFileName buffer, in characters.
Return Value
If the function succeeds, the return value specifies the length of the string copied to the buffer.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
The file Psapi.dll is installed in the %windir%\System32 directory. If there is another copy of this DLL on your computer, it can lead to the following error when running applications on your system: "The procedure entry point GetProcessImageFileName could not be located in the dynamic link library PSAPI.DLL." To work around this problem, locate any versions that are not in the %windir%\System32 directory and delete or rename them, then restart.
The GetProcessImageFileName function returns the path in device form, rather than drive letters. For example, the file name C:\Winnt\System32\Ctype.nls would look as follows in device form:
\Device\Harddisk0\Partition1\WINNT\System32\Ctype.nls
To retrieve the module name of the current process, use the GetModuleFileName function with a NULL module handle. This is more efficient than calling the GetProcessImageFileName function with a handle to the current process.
To retrieve the name of the main executable module for a remote process in win32 path format, use the QueryFullProcessImageName function.
|
