I have a situation where i post a WM_QUIT to shut down
an executing EXE and then wait around for it to terminate.
 
it looks like:
   
    // need to already have the hPID from before
 
    hproc := OpenProcess(SYNCHRONIZE or PROCESS_TERMINATE, False, hPID );
 
    // post the WM_QUIT messages
 
    if (WaitForSingleObject(hproc,wsoWaitTime) <> WAIT_OBJECT_0) then
        // didn't quit within the wsoWaitTime msecs 
    else
        // the process terminated
        // at this point you could GetExitCodeProcess if you care about that.
    end;
 
    if not CloseHandle(hproc) then
        // couldn't close handle error
    end;
 
 
So I guess what i'm suggesting you try is to use WaitForSingleObject to
wait for the process to terminate instead of "polling" the state of the
process with GetExitCodeProcess.
 
hope this is useful
 
-ns
 
 
 
----- Original Message -----
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Wednesday, May 16, 2001 6:26 AM
Subject: [DUG]: Process termination

> Hi All
>
> When a Process is terminating and you are waiting for the process to complete
> its Termination, i.e. waiting on GetExitCodeProcess <> STILL_ACTIVE.
> Does anyone know if there is a temporary state ("error code") returned by
> GetExitCodeProcess, between STILL_ACTIVE and the Process Termination fully
> Completed.
> Something like "Terminating" ???
>
> What we are doing is running the process, waiting for it to terminate, and then
> closing the handles for the Thread and Process, and deleting the EXE.
> Every now and then the close handle fails (The GetExitCodeProcess succeeds) and
> the delete fails.
>
> any help much appreciated...
>
>
> Regards
> Paul McKenzie
>
> =========================
> Paul McKenzie
> Jetbet II Developer
> =========================
>
[EMAIL PROTECTED]
> Ph: (04) 576-6822
>
> T.A.B. National Office
> 106-110 Jackson Street
> Petone
> New Zealand
>
>
>
> ---------------------------------------------------------------------------
>     New Zealand Delphi Users group - Delphi List -
[EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>

Reply via email to