How can I retrieve a process\'s fully-qualified path from its PID using C++ on Windows?
I didn't have very much luck with GetModuleFileNameEx and QueryFullProcessImageName is only available on Vista or higher. I was however able to get the path for a process by using GetProcessImageFilename. It returns the windows kernel path but you can use QueryDosDevice to compare the device path returned by GetProcessImageFilename
with its proper drive path.
This page shows how to normalize an windows kernel path returned by GetProcessImageFilename
(see NormalizeNTPath
function):
http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/c48bcfb3-5326-479b-8c95-81dc742292ab/