AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi Programm starten und warten bis es beendet wird
Thema durchsuchen
Ansicht
Themen-Optionen

Programm starten und warten bis es beendet wird

Ein Thema von meisteralex · begonnen am 8. Feb 2006 · letzter Beitrag vom 8. Feb 2006
 
dfried

Registriert seit: 16. Aug 2005
486 Beiträge
 
#9

Re: Programm starten und warten bis es beendet wird

  Alt 8. Feb 2006, 09:18
@meisteralex: Ich hab den Quelltext von Klausi01 mal noch etwas umgebaut (dann verstehst du Ihn wahrscheinlich besser) und auch schon ein "Application.Processmessages" mit reingemacht. Damit sollte es funktionieren!

Delphi-Quellcode:
{ WindowState is one of the SW_xxx constants.
  Look up ShowWindow in the API help for a list.}

function ExecAndWait(const Filename, Params: string;
                     WindowState: word): boolean;
var
  SUInfo: TStartupInfo;
  ProcInfo: TProcessInformation;
  CmdLine: string;
begin
  { Enclose filename in quotes to take care of
    long filenames with spaces. }

  CmdLine := '"' + Filename + '" ' + Params;
  FillChar(SUInfo, SizeOf(SUInfo), #0);
  with SUInfo do begin
    cb := SizeOf(SUInfo);
    dwFlags := STARTF_USESHOWWINDOW;
    wShowWindow := WindowState;
  end;
  try
    Result := CreateProcess(NIL, PChar(CmdLine), NIL, NIL, FALSE,
                            CREATE_NEW_CONSOLE or
                            NORMAL_PRIORITY_CLASS, NIL,
                            PChar(ExtractFilePath(Filename)),
                            SUInfo, ProcInfo);
  except
    on E: Exception do
      begin
        Result:=false;
      end;
  end;

  { Wait for it to finish. }
  if Result then begin
    Application.Processmessages; // <-- diese Zeile hab ich eingefügt!!!
    WaitForSingleObject(ProcInfo.hProcess, INFINITE);
  end;

end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:36 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz