
How do I detect when a program terminates?
Quote:
> Can anyone tell me how to detect when a program or a
> process terminates?
Did you start it? If so, how. CreateProcess() and ShellExecuteEx() can be
made to return a process handle. A process handle is a synchronization
object which can be tested or waited on. Check the docs for
WaitForSingleObjectEx() or MsgWaitForMultipleObjectsEx().
If you didn't start it, you can try to get a handle after the fact. Check
the docs for Process32First() and Process32Next() or EnumProcesses() if you
target NT4. That should help you find a process ID. Once you have an ID you
can call OpenProcess() to get a process handle. On NT the latter function
may fail for security reasons.
In all cases, don't forget to close the process handle when you are done.
Regards.
Will