QueryFullProcessImageName Function Home
QueryFullProcessImageName Function

Retrieves the full name of the executable image for the specified process.

Syntax

BOOL WINAPI QueryFullProcessImageName(
  __in     HANDLE hProcess,
  __in     DWORD dwFlags,
  __out    LPTSTR lpExeName,
  __inout  PDWORD lpdwSize
);


Parameters

hProcess [in]

A handle to the process. This handle must be created with the PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION access right. For more information, see Process Security and Access Rights.

dwFlags [in]

This parameter can be one of the following values.

ValueMeaning
0

The name should use the Win32 path format.

PROCESS_NAME_NATIVE
0x00000001

The name should use the native system path format.

 

lpExeName [out]

The path to the executable image. If the function succeeds, this string is null-terminated.

lpdwSize [in, out]

On input, specifies the size of the lpExeName buffer, in characters. On success, receives the number of characters written to the buffer, not including the null-terminating character.

Return Value

If the function succeeds, the return value is nonzero.

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

Remarks

To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or later.

Requirements

Minimum supported clientWindows Vista
Minimum supported serverWindows Server 2008
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesQueryFullProcessImageNameW (Unicode) and QueryFullProcessImageNameA (ANSI)

See Also

GetModuleFileNameEx
GetProcessImageFileName
Process and Thread Functions

Send comments about this topic to Microsoft

Build date: 11/19/2009

Community Content

Getting a useful path (same as GetModuleFileNameEx)
Added by:Glyn Davies
Only way seems to be to enumerate the drives, and build up a mapping table
to go from \Device\harddiskvolume1 to C:
The procedure entry point could not be located...
Added by:augu

If you get an error like:

"The procedure entry point QueryFullProcessImageNameW could not be located in the dynamic link library KERNEL32.DLL"

it is because this function is only available on Windows Vista! I got this even after #defining _WIN32_WINNT 0x0600 which I assume should give a more "You must be using vista" style error. Weird.

When I debugged the code of "windows via c/c++" ,this error also appeared,at first,i also added #defining _WIN32_WINNT 0x0600,but it didn't do
Then I looked back up to the book,and found this sentence“To build the applications, you'll need Visual Studio 2005 (or later), the Microsoft Platform SDK for Windows Vista and Windows Server 2008 (which comes with some versions of Visual Studio). In addition, to run the applications, you'll need a computer (or virtual machine) with Windows Vista (or later) installed.”Then I want to ask why don't just tell me"you system isn't windows vista"

For best results use the following
Added by:eriklitze

For the best results use the following table to convert paths.

Windows 2000 = GetModuleFileName()
Windows XP x32 = GetProcessImageFileName()
Windows XP x64 = GetProcessImageFileName()
Windows Vista = QueryFullProcessImageName()
Windows 7 = QueryFullProcessImageName()


Note: If you are not aware the API GetProcessImageFileName() returns a kernel DOS device path. You can use the following API to map the device paths to a Win32 format.

GetLogicalDriveStrings
QueryDosDevice

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View