Closing a process(windows app) created with createprocess.

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

Hi All,

I have an app that starts up an other windowed app using createprocess. Now
when it's time to close i want the other app to close too. How would i do
that?

I also would like to know if the other app got closed (basicly crashed
:-) ), Is there a way to monitor a process if it's still alive?

Thanks in advance,
Richard.
 
You can use toolhelp to enumerate the processes. Do it in a loop evey, say,
100 msec, and wait for the target process to disappear. Just so long as you
do not leave like that - or it'll eat the battery
 
You can wait for a process to exit using WaitForSingleObject (P/Invoke) on
the process handle returned from CreateProcess. If you do that with a
time-out on the Wait, you can decide that, after 20 seconds, if the wait has
not completed, the process is hung and do something about it.

Paul T.
 
Back
Top