0

6 up votes for a comment telling me its a duplicate when it is not. 4 votes to close despite no one reading the actual question. no answer accepted.

I have found a link that explains.

https://hackernoon.com/the-decline-of-stack-overflow-7cb69faa575d#.d05jjnucn

So long SO, account closed.

  • Its not a duplicate. I don't need the pid and I don't care if it is recycled. I only want the image name. –  Dec 13 '16 at 10:58
  • 1
    Ok. So use the technique described in http://stackoverflow.com/questions/185254/how-can-a-win32-process-get-the-pid-of-its-parent to get the parent process PID. Then call OpenProcess() to get the process handle and QueryFullProcessImageName() on the handle to get the image filename. – Andreas H. Dec 13 '16 at 11:02

2 Answers2

0

Assuming you know processA name,

you could use EnumProcesses() to get the list of all processes,

then GetModuleBaseName() to check the name of each process (you will need to open them with OpenProcess() before that)

and when you find the right one : QueryFullProcessImageName() with the Id given by EnumProcesses()

Greg
  • 579
  • 5
  • 26
  • "Assuming you know processA name." I dont know the name of process A. –  Dec 13 '16 at 10:59
  • from this link : https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms684868(v=vs.85).aspx – Greg Dec 13 '16 at 11:25
  • my bad, send the last comment by error. this link : https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms684868(v=vs.85).aspx says "A process can use the Process32First function to obtain the process identifier of its parent process". Maybe it is what you are looking for? – Greg Dec 13 '16 at 11:27
0

Use the technique from https://stackoverflow.com/a/3137081/6172310 to obtain the Process ID (pid) of the parent process.

Call OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid) to get a handle to the process (don't forget to close the handle when you are done!)

Call QueryFullProcessImageName(processHandle, 0, outputString, sizeof(outputString)) to get the image name.

Community
  • 1
  • 1
Andreas H.
  • 1,757
  • 12
  • 24
  • Your trying to fit this solution to my requirement which is not what I am asking. I will edit the question to be more clear. –  Dec 13 '16 at 11:08