Re: Track down name of parent process

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Whoops, that should be `PROCESSENTRY32::th32ParentProcessID'.

--
Ken Johnson (Skywing)
Windows SDK MVP
http://www.nynaeve.net
"Skywing [MVP]" <skywing_NO_SPAM_@xxxxxxxxxxxxxxxxxxx> wrote in message news:%23qs76SFfHHA.4552@xxxxxxxxxxxxxxxxxxxxxxx
This is not guaranteed to be possible, as there is no implicit reference that a process has on its parent.

The documented way to retrieve this information is to get a pid via CreateToolhelp32Snapshot(...TH32CS_SNAPPROCESS...) and use Process32[First|Next] until you find your process, then examining PROCESSENTRY32::th32ProcessID.

However, this is not guaranteed to work. It is quite possible that the parent process has died and the saved parent process ID has already been recycled and used by a different process (or is plain invalid). There is no way to detect this conditon, as parent-child process relationships are not `enforced' by the operating system beyond creation tine inheritance.

--
Ken Johnson (Skywing)
Windows SDK MVP
http://www.nynaeve.net
"Karin Baumann" <BaBaum@xxxxxx> wrote in message news:584abiF2drkasU1@xxxxxxxxxxxxxxxxxxxxx
Hi,

how can a program find the name of the parent-process, i.e. the process it was started from?


.



Relevant Pages