Autor Beitrag
Timelesk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 82


Delphi 2006 Prof
BeitragVerfasst: Fr 10.08.07 11:19 
Hallo,

ich arbeite derzeit an einem AutoInstaller für Programme.
Dazu lasse ich die Setup.exe starten und über SendMessage bzw. Postmessage Tastatureingaben simulieren.

Nun ist aber das Problem, dass z.B. die Installation (kopieren der Daten, Registry-Einträge, etc.) einige Zeit dauert.
Ich habe es derzeit so, dass das Programm einfach 1 Minute wartet, bis es fortfährt.

Gibt es eine Möglichkeit zu Prüfen, ob ein Programm, von dem ich das Handle habe, derzeit aktiv ist?
Ob es derzeit arbeitet?


Vielen Dank

gruß
Timelesk
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 10.08.07 11:48 
Prüfe in regelmäßigen Abständen, ob der Prozess noch existiert. Z.B. kannst Du GetWindowThreadProcessId nutzen, wenn Du das Handle kennst.
arj
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 378

Win XP/Vista, Debian, (K)Ubuntu
Delphi 5 Prof, Delphi 7 Prof, C# (#Develop, VS 2005), Java (Eclipse), C++, QT, PHP, Python
BeitragVerfasst: Fr 10.08.07 12:08 
Du kannst auch einfach die Funktion WaitForObject nehmen. Die ist für sowas da. ;)
Timelesk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 82


Delphi 2006 Prof
BeitragVerfasst: Fr 10.08.07 13:33 
Hallo,

@jasocul: Mit GetWindowThreadProcessId bekomme ich ja nur die ProcessId des aktuellen Prozesses raus und wenn ich z.B. in Notepad mehrere Zeilen schreiben lasse, dann ist diese ID immer gleich.

@arj: Bezüglich WaitForObject hab ich jetzt nichts gefunden. Lediglich ein Thema, dass sich aber mit Threads befasst hat. Delphi kennt den Befehl auch nicht.
Kannst du mir evtl. ein Beispiel geben?


Vielen Dank

gruß
Timelesk
arj
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 378

Win XP/Vista, Debian, (K)Ubuntu
Delphi 5 Prof, Delphi 7 Prof, C# (#Develop, VS 2005), Java (Eclipse), C++, QT, PHP, Python
BeitragVerfasst: Fr 10.08.07 14:27 
Sorry, die Funktion heißt

WaitForSingleObject

dann solltest du es auch finden ;)

Beispiel hab ich momentan keine Zeit. Aber solltest im Forum eines finden.

msdn2.microsoft.com/...ibrary/ms687032.aspx
AHT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 207



BeitragVerfasst: Mo 20.08.07 14:28 
Hallo Timelesk...

Wenn du die Setup über CreateProcess startest, bekommst du über die PROCESS_INFORMATION Struktur (letzter Parameter von CreateProcess) ein gültiges Handle auf den gestarteten Prozess zurückgeliefert. Dieses Handle kannst du mit der API GetExitCodeProcess verwenden und darüber prüfen, ob der gestartete Prozess noch läuft.

Gruß

AHT