Einzelnen Beitrag anzeigen

Ianisp

Registriert seit: 15. Nov 2005
Ort: Dresden
2 Beiträge
 
Delphi 7 Enterprise
 
#14

Re: Programm starten und auf Programmende warten

  Alt 15. Nov 2005, 14:52
Hi Aike,

Probiere mal das:

Delphi-Quellcode:
procedure TMainForm.runProcess(ExeName, Parameter: String; wait: boolean);
var SUInfo: TStartupInfo;
    ProcInfo: TProcessInformation;
    bool:boolean;
begin
   FillChar(SUInfo, SizeOf(SUInfo), #0);
   with SUInfo do begin
     cb := SizeOf(SUInfo);
     dwFlags := STARTF_USESHOWWINDOW;
   end;
   bool := CreateProcess(NIL, PChar(EXEName+' '+Parameter), NIL, NIL, FALSE,
                           CREATE_NEW_CONSOLE or
                           NORMAL_PRIORITY_CLASS, NIL,
                           PChar(ApplicationDir),
                           SUInfo, ProcInfo);
   if (bool)and(wait) then
     while WaitForSingleObject(ProcInfo.hProcess, 100 {INFINITE})=WAIT_TIMEOUT do begin
        //refresh;
        Application.ProcessMessages;
        if Application.Terminated then
           Break;
     end;
end;
  Mit Zitat antworten Zitat