Re: Track down name of parent process
- From: "Skywing [MVP]" <skywing_NO_SPAM_@xxxxxxxxxxxxxxxxxxx>
- Date: Thu, 12 Apr 2007 16:18:48 -0400
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@xxxxxxxxxxxxxxxxxxxxxHi,
how can a program find the name of the parent-process, i.e. the process it was started from?
.
- References:
- Track down name of parent process
- From: Karin Baumann
- Re: Track down name of parent process
- From: Skywing [MVP]
- Track down name of parent process
- Prev by Date: Re: Monitor a child process of a parent process,...
- Next by Date: Re: Track down name of parent process
- Previous by thread: Re: Track down name of parent process
- Next by thread: Re: Track down name of parent process
- Index(es):
Relevant Pages
|