How do I detect when a program terminates? 
Author Message
 How do I detect when a program terminates?


Can anyone tell me how to detect when a program or a
process terminates? I am writing a automatic installation
program that automatically update programs in the system,
and i want to know when a program P terminates, so that I
can proceed with updating P.

thanks a lot

Wed, 16 Feb 2005 06:50:44 GMT  
 How do I detect when a program terminates?

> 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.


Wed, 16 Feb 2005 09:46:20 GMT  
 [ 2 post ] 

 Relevant Pages 

1. terminating thread while WIN32 socket doing recv( )

2. How to detect screen saver terminate..

3. Detect when NotePad is terminating

4. terminate a program

5. using the string xxx or XXX as a means of terminating the program


7. Code compiles but program terminates with error

8. Terminating last output of a program with a newline

9. Program cannot terminated, please help ?

10. terminating a program with 'exit'

11. Q: Terminating program at EOF

12. is MALLOCed memory freed up when program terminates


Powered by phpBB® Forum Software