We have developed the following procedure to simplify the use of
CreateProcess and WaitForSingle object.
This will execute the program, and wait for it to finish.
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;
Stacey
> -----Original Message-----
> From: Jeremy Coulter [mailto:[EMAIL PROTECTED]]
> Sent: Friday, 5 May 2000 11:44 a.m.
> To: Multiple recipients of list delphi
> Subject: [DUG]: executing an app...and waiting till its finished.
>
>
> HI all.
>
> I am wanting to execute an app form another app (in this case
> an Autorun
> fiel I have written to go on an Install CD) but not move to
> the next step
> UNTIL the the app that was execute has finished?
>
> Would I be best to look for the handle of the app ever few
> seconds, then
> when its not there move to the next bit etc. ??
>
> Cheers, Jeremy Coulter
>
> --------------------------------------------------------------
> -------------
> 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