how to check if a process has really been started?
-
hiho@ll you can start a new process with CreateProcess (or system,...) i think everybody knows my question: (i think it will only work with creatprocess function) how can i know if the process has really been started? (maybe the file has been deleted, or the app i want to start is single instance app and another instance is running, or the file has been damaged during download ,...) how do i know what happend and if the process has been started or not, and if not, why not thx@ll
-
hiho@ll you can start a new process with CreateProcess (or system,...) i think everybody knows my question: (i think it will only work with creatprocess function) how can i know if the process has really been started? (maybe the file has been deleted, or the app i want to start is single instance app and another instance is running, or the file has been damaged during download ,...) how do i know what happend and if the process has been started or not, and if not, why not thx@ll
-
hiho@ll you can start a new process with CreateProcess (or system,...) i think everybody knows my question: (i think it will only work with creatprocess function) how can i know if the process has really been started? (maybe the file has been deleted, or the app i want to start is single instance app and another instance is running, or the file has been damaged during download ,...) how do i know what happend and if the process has been started or not, and if not, why not thx@ll
Technicaly, the answer of toxcct is correct :-). But I suppose you want to check that in your code ? I think one solution could be to use the handle of the process that is 'supplied' in the LPPROCESS_INFORMATION structure after CreateProcess is called. Then, with that handle, you can call GetExitCodeStatus and check if the lpExitCode == STILL_ACTIVE . Hope this helps
-
this means i have to check what processes are currently running 1. don't really know how i can check this, using my prog :-( 2. what if it's a single instance app and i check the task manager i will find the process, but it's not the process i wanted to start! it's another! so how can i check if the process i wanted to start has been started? thx
-
Technicaly, the answer of toxcct is correct :-). But I suppose you want to check that in your code ? I think one solution could be to use the handle of the process that is 'supplied' in the LPPROCESS_INFORMATION structure after CreateProcess is called. Then, with that handle, you can call GetExitCodeStatus and check if the lpExitCode == STILL_ACTIVE . Hope this helps
thx i'll check it ;-)
-
hiho@ll you can start a new process with CreateProcess (or system,...) i think everybody knows my question: (i think it will only work with creatprocess function) how can i know if the process has really been started? (maybe the file has been deleted, or the app i want to start is single instance app and another instance is running, or the file has been damaged during download ,...) how do i know what happend and if the process has been started or not, and if not, why not thx@ll
While you can use
GetExitCodeThread()
for this, a well-behaved application should not be concerned with what other threads are doing. By having threads communicate back and forth, you've effectively added an unnecessary level of complication to the application. The primary thread should create the other threads, give them a job to do, and then go off and do something else while not waiting around wondering about those threads. These other threads can then communicate back to the primary thread (e.g.,PostMessage()
) as to what their status is.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-- modifed at 13:45 Thursday 25th August, 2005
-
this means i have to check what processes are currently running 1. don't really know how i can check this, using my prog :-( 2. what if it's a single instance app and i check the task manager i will find the process, but it's not the process i wanted to start! it's another! so how can i check if the process i wanted to start has been started? thx
If CreateProcess returns TRUE, then the process was started. If the program is a windowed application, you can use WaitforInputIdle to make sure it got a window up on the screen. A well-deisgned application that is only going ot allow a single instance to run would terminate before displaying any user interface. So if WaitForInputIdle times out, your other app is slow, or stopped. If you think it stopped, you can test the process handle to see if the handle is signaled - they are signaled if application is no longer running. You can use the process identifier returned from the CreateProcess call and compare it with the results of a call to EnumProcesses to see if the process identifier is still present.
-
hiho@ll you can start a new process with CreateProcess (or system,...) i think everybody knows my question: (i think it will only work with creatprocess function) how can i know if the process has really been started? (maybe the file has been deleted, or the app i want to start is single instance app and another instance is running, or the file has been damaged during download ,...) how do i know what happend and if the process has been started or not, and if not, why not thx@ll
look into WaitForInputIdle()
-
If CreateProcess returns TRUE, then the process was started. If the program is a windowed application, you can use WaitforInputIdle to make sure it got a window up on the screen. A well-deisgned application that is only going ot allow a single instance to run would terminate before displaying any user interface. So if WaitForInputIdle times out, your other app is slow, or stopped. If you think it stopped, you can test the process handle to see if the handle is signaled - they are signaled if application is no longer running. You can use the process identifier returned from the CreateProcess call and compare it with the results of a call to EnumProcesses to see if the process identifier is still present.
thx blake seems simple i'll check it out