Einzelnen Beitrag anzeigen

Benutzerbild von APP
APP

Registriert seit: 24. Feb 2003
Ort: Graz (A)
705 Beiträge
 
Delphi 7 Enterprise
 
#3

Re: warten bis ShellExecute beendet ist

  Alt 14. Aug 2004, 16:25
Hallo eddy,
das Warten bis ein Prozess beendet wurde funkt nur mit Hier im Forum suchenCreateProcess oder mit ShellExecuteEx:

Anbei ein Beispliel mit ShellExecuteEx:
Delphi-Quellcode:
{******************************************************************************}
FUNCTION StartAndWait(CONST ExecuteFile, ParamString: STRING): boolean;
//http://delphi.about.com/library/weekly/aa040803a.htm
{******************************************************************************}
VAR
  SEInfo : TShellExecuteInfo;
  ExitCode : DWORD;
BEGIN
  Result := False;
  IF NOT FileExists(ExecuteFile) THEN Exit;
  FillChar(SEInfo, SizeOf(SEInfo), 0);
  SEInfo.cbSize := SizeOf(TShellExecuteInfo);
  WITH SEInfo DO
    BEGIN
      fMask := SEE_MASK_NOCLOSEPROCESS;
      Wnd := Application.Handle;
      lpFile := PChar(ExecuteFile);
      lpParameters := PChar(ParamString);
      nShow := SW_SHOWNORMAL;
    END;
  IF ShellExecuteEx(@SEInfo) THEN
    BEGIN
      REPEAT
        Application.ProcessMessages;
        // Damit die Prozessorauslastung sinkt :-)
        Sleep(100);
        GetExitCodeProcess(SEInfo.hProcess, ExitCode);
      UNTIL (ExitCode <> STILL_ACTIVE) OR Application.Terminated;
      Result := True;
    END;
END;
Armin P. Pressler

BEGIN
...real programmers are using C/C++ - smart developers Delphi;
END;
  Mit Zitat antworten Zitat