Skip to content

Latest commit

 

History

History
133 lines (94 loc) · 6.27 KB

nf-psapi-getprocessimagefilenamea.md

File metadata and controls

133 lines (94 loc) · 6.27 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:psapi.GetProcessImageFileNameA
GetProcessImageFileNameA function (psapi.h)
Retrieves the name of the executable file for the specified process. (ANSI)
GetProcessImageFileNameA
K32GetProcessImageNameA
K32GetProcessImageNameW
psapi/GetProcessImageFileNameA
psapi/K32GetProcessImageNameA
psapi/K32GetProcessImageNameW
psapi\getprocessimagefilename.htm
psapi
819fc2f4-0801-417b-9cbb-d7fd2894634e
12/05/2018
GetProcessImageFileName, GetProcessImageFileName function [PSAPI], GetProcessImageFileNameA, GetProcessImageFileNameW, K32GetProcessImageFileName, K32GetProcessImageNameA, K32GetProcessImageNameW, _win32_getprocessimagefilename, base.getprocessimagefilename, psapi.getprocessimagefilename, psapi/GetProcessImageFileName, psapi/GetProcessImageFileNameA, psapi/GetProcessImageFileNameW, psapi/K32GetProcessImageFileName, psapi/K32GetProcessImageNameA, psapi/K32GetProcessImageNameW
psapi.h
Windows
Windows XP [desktop apps only]
Windows Server 2003 [desktop apps only]
GetProcessImageFileNameW (Unicode) and GetProcessImageFileNameA (ANSI)
Kernel32.lib on Windows 7 and Windows Server 2008 R2; Psapi.lib (if PSAPI_VERSION=1) on Windows 7 and Windows Server 2008 R2; Psapi.lib on Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP
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
Windows
19H1
GetProcessImageFileNameA
psapi/GetProcessImageFileNameA
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
Psapi.dll
Psapi.dll
GetProcessImageFileName
GetProcessImageFileNameA
GetProcessImageFileNameW
K32GetProcessImageFileName
K32GetProcessImageNameW
K32GetProcessImageNameA

GetProcessImageFileNameA function

-description

Retrieves the name of the executable file for the specified process.

-parameters

-param hProcess [in]

A handle to the process. The handle must have the PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION access right. For more information, see Process Security and Access Rights.

Windows Server 2003 and Windows XP:  The handle must have the PROCESS_QUERY_INFORMATION access right.

-param lpImageFileName [out]

A pointer to a buffer that receives the full path to the executable file.

-param nSize [in]

The size of the lpImageFileName buffer, in characters.

-returns

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:\Windows\System32\Ctype.nls would look as follows in device form:

\Device\Harddisk0\Partition1\Windows\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.

Starting with Windows 7 and Windows Server 2008 R2, Psapi.h establishes version numbers for the PSAPI functions. The PSAPI version number affects the name used to call the function and the library that a program must load.

If PSAPI_VERSION is 2 or greater, this function is defined as K32GetProcessImageFileName in Psapi.h and exported in Kernel32.lib and Kernel32.dll. If PSAPI_VERSION is 1, this function is defined as GetProcessImageFileName in Psapi.h and exported in Psapi.lib and Psapi.dll as a wrapper that calls K32GetProcessImageFileName.

Programs that must run on earlier versions of Windows as well as Windows 7 and later versions should always call this function as GetProcessImageFileName. To ensure correct resolution of symbols, add Psapi.lib to the TARGETLIBS macro and compile the program with -DPSAPI_VERSION=1. To use run-time dynamic linking, load Psapi.dll.

Note

The psapi.h header defines GetProcessImageFileName as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

PSAPI Functions

Process Information

QueryFullProcessImageName