Hallo,<p>
<b>Problem:</b> Die eigene Delphi-Anwendung soll ein anderes Programm mit Parameter (Optionen) starten.<br>
<b>Lösung:</b><pre>
begin
ShellExecute(0, nil, PCHAR('test.exe'), PCHAR('-o'), 0, SW_SHOW);
end;
</pre>
<b>Resultat:</b> Die Anwendung wird mit dem Parameter gestartet.<p>
Nun sollte folgende Änderung eingebaut werden:<br>
Das eigene Programm soll warten, bis die gestartet Anwendung beendet ist.<bR>
<b>Lösung:</b><pre>
var
aSI : TStartupInfo;
aPI : TProcessInformation;
aProc : THandle;
begin
FillChar(aSI, SizeOf(aSI), 0);
aSI.cb := SizeOf(aSI);
aSI.wShowWindow := wShow;
Win32Check(CreateProcess(PChar('test.exe'), PChar('-o'), nil, nil,
False, Normal_Priority_Class, nil, nil, aSI, aPI));
aProc := aPI.hProcess;
CloseHandle(aPI.hThread);
if WaitForSingleObject(aProc, Infinite) <> Wait_Failed then
GetExitCodeProcess(aProc, Result);
CloseHandle(aProc);
end;</pre>
<b>Resultat:</b> Die Anwendung wird gestartet, das eigene Programm wartet, bis das gestartet Programm beendet worden ist - aber: der Parameter wurde <u>nicht</u> mit übergeben.<p>
Ich benutze Delphi 5. Hat jemand eine Idee, Lösung bzw. kennt dem Fehler?
<b>Problem:</b> Die eigene Delphi-Anwendung soll ein anderes Programm mit Parameter (Optionen) starten.<br>
<b>Lösung:</b><pre>
begin
ShellExecute(0, nil, PCHAR('test.exe'), PCHAR('-o'), 0, SW_SHOW);
end;
</pre>
<b>Resultat:</b> Die Anwendung wird mit dem Parameter gestartet.<p>
Nun sollte folgende Änderung eingebaut werden:<br>
Das eigene Programm soll warten, bis die gestartet Anwendung beendet ist.<bR>
<b>Lösung:</b><pre>
var
aSI : TStartupInfo;
aPI : TProcessInformation;
aProc : THandle;
begin
FillChar(aSI, SizeOf(aSI), 0);
aSI.cb := SizeOf(aSI);
aSI.wShowWindow := wShow;
Win32Check(CreateProcess(PChar('test.exe'), PChar('-o'), nil, nil,
False, Normal_Priority_Class, nil, nil, aSI, aPI));
aProc := aPI.hProcess;
CloseHandle(aPI.hThread);
if WaitForSingleObject(aProc, Infinite) <> Wait_Failed then
GetExitCodeProcess(aProc, Result);
CloseHandle(aProc);
end;</pre>
<b>Resultat:</b> Die Anwendung wird gestartet, das eigene Programm wartet, bis das gestartet Programm beendet worden ist - aber: der Parameter wurde <u>nicht</u> mit übergeben.<p>
Ich benutze Delphi 5. Hat jemand eine Idee, Lösung bzw. kennt dem Fehler?
Comment