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?
Printable View
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?
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.
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.
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.