|
Boost : |
From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2006-07-13 09:05:54
Although I'm not familiar with the context for this code, I have
a little comment...
> + {
> + /* explorer.exe is orphaned and process_id of its parent may
> + accidentally match process_id of process we are after. We must not
> + close dialog boxes displayed by children of explorer.exe even
> + though (thanks to its parent process id) it might appear to be
> + our child. This is not very reliable - there might be more
> + orphaned processes or shell might be something else than
> + explorer.exe, but this is most common and important scenario */
You may be able to use GetProcessTimes on the process handle
to determine the creation time of the particular process. If it
is older than the time at which the parent spawned child
processes, then even though it might appear to be a child it almost
certainly isn't. Conversely if the creation time is after, then
you can almost certainly say it is a child process.
(Note that even this isn't perfect, since the system clock can
be changed, but it's probably more reliable.)
Cheers,
Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk