Possible Duplicate:
Determine the parent process of the current app
I would like to get the a MainProcess Handle or PID of a process.
For example Google Chrome drops another processes for each tab which are actually threads.
In ProcessExplorer it shows chrome.exe in the treeview as a mainprocess and the threads underneath it. How could I check or get the MainProcess Handle/PID? Something like a WindowsAPI?
Thanks for your help.
@RRUZ has already answered an almost identical question on Stack Overflow. However, the code there is incorrect in that it declares process IDs as
THandle. The following corrects the mistakes that I found, and also adapts the routine to return a PID rather than a filename:I know that this is a duplicate question, but the code here is precisely what the OP wants, so I’ll leave it visible for a while at least.