![]() |
AW: Too stupid to execute and wait
Für INFINITE könnte man noch einen ausreichend langen Timeout setzen, damit eventuelle Deadlocks gleich mit abgefangen werden.
|
AW: Too stupid to execute and wait
Ich würde vielleicht noch einmal überdenken, ob die verwendeten Flags wirklich zielführend sind. Vielleicht sollte man ja die folgende Kombination verwenden:
SEE_MASK_NOCLOSEPROCESS or SEE_MASK_WAITFORINPUTIDLE or SEE_MASK_NOZONECHECKS Dann kann man sich vermutlich auch all dieses Application.ProcessMessages-gefrickel sparen. |
AW: Too stupid to execute and wait
Hallo,
da seh ich gerade noch:
Delphi-Quellcode:
Hier sollte das A hinten noch weg.
ShExecInfo.cbSize := sizeof(SHELLEXECUTEINFOA);
Und dann noch eine Frage zu dem WaitFor: Sollte man hier nicht auch auf Application.Terminated prüfen? Ist vielleicht eine Glaubensfrage für den Anwendungsfall aber ich würde es machen. Also etwa so:
Delphi-Quellcode:
Gruß, Chris
repeat
RetValue := MsgWaitForMultipleObjects(1, ShExecInfo.hProcess, False, INFINITE, QS_ALLINPUT); if RetValue <> WAIT_OBJECT_0 then Application.ProcessMessages; until (RetValue = WAIT_OBJECT_0) or Application.Terminated; |
AW: Too stupid to execute and wait
Das ProcessMessages sorgt dafür, das der Thread (Hauptthread) nicht "einschläft"
WAITFORINPUTIDLE wartet "nur" bis das gestartete programm "aufnahmebereit" ist, wärend das MsgWaitFor (ohne MsgWaitFor) auf die komplette Beendigung des Programms wartet. |
AW: Too stupid to execute and wait
Zitat:
oder hat das damit nichts zu tun? |
AW: Too stupid to execute and wait
Zitat:
Aber wieso erspart mir diese flag kombination das ProcessMessages? |
AW: Too stupid to execute and wait
Zitat:
|
AW: Too stupid to execute and wait
Noch ne frage
wo wir gerade am tunen sind...
Delphi-Quellcode:
Oder
ShExecInfo.Wnd := application.MainFormHandle;
Delphi-Quellcode:
Oder
ShExecInfo.Wnd := application.Handle;
Delphi-Quellcode:
ShExecInfo.Wnd := GetForegroundWindow;
|
AW: Too stupid to execute and wait
Zitat:
|
AW: Too stupid to execute and wait
MainFormHandle kannte mein D7 nicht, deswegen nur Handle. Und GetForeGroundWindow ist gefährlich, da dein Programmfenster beim ausführen des Codes nicht das oberste Fenster sein muss.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:42 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