CreateProcess will allow you to execute an application and wait for it to
finish. Its not too simple to use though. The following is a wrapper
function that we use:

function ExecuteApplication(PPath, PFileName, PParameters : String):
Boolean;
var     LStartUp: TStartupInfo;
        LProcess: TProcessInformation;
begin
//      ShowMessage(PPath + ' ' + PFileName + ' ' + PParameters);
        Result := True;

        try
                FillChar(LStartUp, SizeOf(LStartUp), 0);
                LStartUp.cb := SizeOf(LStartUp);

                Win32Check
                        (
                        CreateProcess
                                (
                                PChar(PFileName)
                                , PChar(PFileName + ' ' + PParameters)
                                , nil
                                , nil
                                , True
                                , 0, nil
                                , PChar(PPath)
                                , lStartUp
                                , lProcess
                                )
                        );

                CloseHandle(LProcess.HThread);
                WaitForSingleObject(LProcess.HProcess, INFINITE);
                CloseHandle(LProcess.HProcess);
        except
                Result := false;
        end;
end;

> -----Original Message-----
> From: Phil Scadden [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 22 March 2000 11:47
> To: Multiple recipients of list DELphi
> Subject: [DUG]: shelling programs in sequence...
> 
> 
> I want run a program sandwiched between two others.
> Ie.
> First program runs: it starts another program (a 16 bit one). 
> When the second
> program completes, I want to pretty much guarantee that a 3rd 
> program runs
> the moment the finishes - whatever the exit status. Both 
> first and 2nd programs
> have minimal but vital execution to perform. I dont have 
> source for the 2nd program.
> 
> I guess the first program shellexecutes the second, hides 
> itself and waits for
> second program to complete. How does it detect second program done?
> 
> Ideas please??
> 
> ----------------------------------------------------------
> Phil Scadden, Institute of Geological and Nuclear Sciences
> PO Box 30368, Lower Hutt, New Zealand
> Ph +64 4 5704821, fax +64 4 5704603
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> 
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to