How can I tell if an app has shut down?
-
I have an program (P1) that runs a long (and unattended) process and then terminates when that process is complete. I do not have the source code for this program and so have no way to change it's behaviour. I can write another program that can start another process, but I need to start it when P1 has completed it's job and not before. So I need a way of detecting when P1 has finished and use that event to start my program. Any help here? Paresh Solanki hombre que trabaja pierde tempo precioso "The man who works is losing precious time." Vuemme
-
I have an program (P1) that runs a long (and unattended) process and then terminates when that process is complete. I do not have the source code for this program and so have no way to change it's behaviour. I can write another program that can start another process, but I need to start it when P1 has completed it's job and not before. So I need a way of detecting when P1 has finished and use that event to start my program. Any help here? Paresh Solanki hombre que trabaja pierde tempo precioso "The man who works is losing precious time." Vuemme
If your program launches P1, then you can use...
WaitForSingleObject(hProcess, INFINITE);
This function will not return until the created process is terminated. After P1 is done, then you can call the third program. Jeremy L. Falcon Homepage : Sonork = 100.16311
"But everybody darlin' sometimes bites the hand that feeds." "Remember in this game we call life that no one said it's fair." "Just because you're winnin' don't mean you're the lucky ones." Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses -
I have an program (P1) that runs a long (and unattended) process and then terminates when that process is complete. I do not have the source code for this program and so have no way to change it's behaviour. I can write another program that can start another process, but I need to start it when P1 has completed it's job and not before. So I need a way of detecting when P1 has finished and use that event to start my program. Any help here? Paresh Solanki hombre que trabaja pierde tempo precioso "The man who works is losing precious time." Vuemme
Use CreateProcess() to start P1. You will get new process handle in the last parameter PROCESS_INFORMATION structure - hProcess. Then you can use this handle to wait for completion of that proces as a parameter for WaitForSingleObject() function. After call to WaitForSingleObject() will finish, you can get exit code of proces with GetExitCodeProcess(), if you will need it. Then you can start it again.
-
If your program launches P1, then you can use...
WaitForSingleObject(hProcess, INFINITE);
This function will not return until the created process is terminated. After P1 is done, then you can call the third program. Jeremy L. Falcon Homepage : Sonork = 100.16311
"But everybody darlin' sometimes bites the hand that feeds." "Remember in this game we call life that no one said it's fair." "Just because you're winnin' don't mean you're the lucky ones." Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' RosesThanks, but I have no control over when P1 runs. I just need to know when it's completed. I cannot start P1 from within my app because I have no control over when it should start. Paresh Solanki hombre que trabaja pierde tempo precioso "The man who works is losing precious time." Vuemme
-
Thanks, but I have no control over when P1 runs. I just need to know when it's completed. I cannot start P1 from within my app because I have no control over when it should start. Paresh Solanki hombre que trabaja pierde tempo precioso "The man who works is losing precious time." Vuemme
Ok, in that case you need to use the psapi.dll... look into code project, you can find a class that look in all process, if you don't find the P1 running, is because the application finished ;) Best Regards Carlos Antollini. www.wanakostudios.com Sonork ID 100.10529 cantollini
-
I have an program (P1) that runs a long (and unattended) process and then terminates when that process is complete. I do not have the source code for this program and so have no way to change it's behaviour. I can write another program that can start another process, but I need to start it when P1 has completed it's job and not before. So I need a way of detecting when P1 has finished and use that event to start my program. Any help here? Paresh Solanki hombre que trabaja pierde tempo precioso "The man who works is losing precious time." Vuemme
What Martin said is best, but you could also use FindWindow in a while loop. As soon as the window has closed, it will not be found by FindWindow so drop out of the loop.
Jason Henderson
quasi-homepage
articles
"Like it or not, I'm right!"