
Get location of file from ProcessID
I have the ID of a process and I want to find out the location of the
executable on the harddisk for that process.
I'm aware of the method:
DWORD GetModuleFileName(
HMODULE hModule, // handle to module to find filename for
LPTSTR lpFilename, // pointer to buffer to receive module path
DWORD nSize // size of buffer, in characters
);
but that relies on having a HMODULE and
HANDLE OpenProcess(
DWORD dwDesiredAccess, // access flag
BOOL bInheritHandle, // handle inheritance flag
DWORD dwProcessId // process identifier
);
only supplies a HANDLE. How can I do this?
Cheers
Stephen