![]() |
ShellExecute - Warten bis Prog beendet wird funzt nicht
Hallo,
folgenden Code, zu Teilen aus folgendem Beitrag zusammengebastelt: ![]() funktioniert leider nicht, und zwar wird die FOR-TO-Schleife bis zum Ende durchgelaufen, und nicht auf den Abschluss des Programms gewartet:
Delphi-Quellcode:
Jemand ne Idee, woran das liegen kann?
procedure Tf_main.bt_startClick(Sender: TObject);
var i : Integer; Info: TShellExecuteInfo; pInfo: PShellExecuteInfo; exitCode: DWord; begin for i := 0 to inst_Prog - 1 do begin pInfo := @Info; with Info do begin cbSize := SizeOf(Info); fMask := SEE_MASK_NOCLOSEPROCESS; wnd := Application.Handle; lpVerb := NIL; lpFile := PChar(lab_ProgExe[i].Caption); {Parametros al ejecutable} {Executable parameters} lpParameters := PChar(lab_ProgParam[i].Caption + #0); lpDirectory := PChar(lab_ProgPfad[i].Caption); nShow := 1; hInstApp := 0; end; ShellExecuteEx(pInfo); repeat exitCode := WaitForSingleObject(Info.hProcess, 500); Application.ProcessMessages; until (exitCode <> WAIT_TIMEOUT); end; Danke im Vorraus tyler |
Re: ShellExecute - Warten bis Prog beendet wird funzt nicht
Zitat:
versuchs mal mit INFINITE statt 500 |
Re: ShellExecute - Warten bis Prog beendet wird funzt nicht
hm, danke, hab ich probiert, hat leider nicht geholfen :(
|
Re: ShellExecute - Warten bis Prog beendet wird funzt nicht
Delphi-Quellcode:
Dieser Code von Delphi Source funktioiert
function Starte(verz, appname: string): boolean;
var StartupInfo: TStartupInfo; ProcessInfo: TProcessInformation; begin if verz[length(verz)]<>'\' then verz:=verz+'\'; FillChar(StartupInfo, SizeOf(TStartupInfo),0); StartupInfo.cb:=SizeOf(TStartupInfo); if CreateProcess(nil, PChar(verz+appname), nil, nil, false, NORMAL_PRIORITY_CLASS, nil, nil, startupinfo, ProcessInfo) then begin try WaitForSingleObject(ProcessInfo.hProcess, INFINITE); finally CloseHandle(ProcessInfo.hProcess); CloseHandle(ProcessInfo.hThread); end; result:=true; end else result:=false; end; |
Re: ShellExecute - Warten bis Prog beendet wird funzt nicht
Danke für den unteren Code! Er funktinioniert ja auch grundsätzlich, nur leider nicht, sobald ich Paramter mit übergeben möchte:
Delphi-Quellcode:
hab ich ersetzt durch (Parameter hinzugefügt) - natürlich nach entsprechender Änderung des Funktionskopfes
if CreateProcess(nil, PChar(verz+appname), nil, nil, false,
NORMAL_PRIORITY_CLASS, nil, nil, startupinfo, ProcessInfo) then begin
Delphi-Quellcode:
Wenn ich das so ausführe, wird die o.g. FOR-TO-Schleife wieder bis zum Ende durchgelaufen (Zur Info, das Programm, welches u.a. gestartet wird, ist eine "Silent"-Installation von WinRAR... vielleicht liegts ja daran?)
if CreateProcess(nil, PChar(verz+appname+' '+parameter), nil, nil, false,
NORMAL_PRIORITY_CLASS, nil, nil, startupinfo, ProcessInfo) then begin tyler |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:47 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