Hallo eddy,
das Warten bis ein Prozess beendet wurde funkt nur mit
CreateProcess 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;