Click to See Complete Forum and Search --> : Detect when another program closes


ws47
July 2nd, 2009, 09:25 PM
I want to be able to detect when another program exits. For example, if i exit my browser, i want my program to detect this and launch another process. How do i do this?

boudino
July 3rd, 2009, 02:33 AM
If you are the one who start the process, you have the Process instance and you can wait for its exit. Otherwise (but there definitelly must be a better solution) you could periodically check the list of running process and if the one which you are interested in is there any more, you can suppose that it has finished.

Shuja Ali
July 3rd, 2009, 02:18 PM
If the application is not launched from your own program then another way would be to hook into the application in question here and trap WM_CLOSE message, but that would require good understanding of APIs.

memeloo
July 3rd, 2009, 02:45 PM
If the application is not launched from your own program then another way would be to hook into the application in question here and trap WM_CLOSE message, but that would require good understanding of APIs.
oh yes, I've tried it once ;] and I managed to crash or hang Vista many many times

HanneSThEGreaT
July 4th, 2009, 03:29 AM
I think you could use the PeekMessage or GetMessage APIs to determine the WM_CLOSE event, it is a bit tricky though...
I'd also periodically loop through all running processes to determine this.