Board index » delphi » executing an external program

executing an external program

Hi all,

Sorry about the stupid question: how can I execute an exe file,
if I want to wait until it finish? (RTFM didn't help... :( )
Someone suggested me the ShellExecute() function, but it does not
wait until the program finish. :(

Please cc to my eng...@all.hu address too, as I can't read the
group regularly!

Thx:
Circum

 

Re:executing an external program


Try:

function RunProcessWait(Command: String): Boolean;
var
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
begin
  with StartupInfo do
  begin
    cb := sizeof(StartupInfo);
    lpreserved := nil;
    lpdesktop := nil;
    lptitle := nil;
    dwflags := 0;
    cbreserved2 := 0;
    lpreserved2 := nil;
    dwFlags := 0;
  end;
  Result := CreateProcess(nil, PChar(Command), nil, nil, False,
    NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);
  if Result then
    WaitforSingleObject(ProcessInfo.hProcess, INFINITE);
end;

"Engard Ferenc" <eng...@all.hu> schreef in bericht
news:390F337A.3EC2C256@all.hu...

Quote
> Hi all,

> Sorry about the stupid question: how can I execute an exe file,
> if I want to wait until it finish? (RTFM didn't help... :( )
> Someone suggested me the ShellExecute() function, but it does not
> wait until the program finish. :(

> Please cc to my eng...@all.hu address too, as I can't read the
> group regularly!

> Thx:
> Circum

Other Threads