Autor Beitrag
Adrian
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 314



BeitragVerfasst: Mi 17.12.03 19:17 
Servus!

Mein Programm soll eine fremde Anwendung starten und sich danach minimieren - das funktioniert schon. Wenn das fremde Programm beendet wird, soll sich dann das Fenster wieder auf die vorherige Größe einstellen. Welche Meldung kann/muß ich abfangen bzw. wie kann ich das Ende der fremden Anwendung feststellen?

Gruß,

Adrian
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 17.12.03 19:25 
Erzeuge den fremden Prozess mit CreateProcess. Damit kannst du auf dessen Beendigung warten.
Coder84
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 26



BeitragVerfasst: Fr 09.01.04 13:48 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var h:HWND;
begin
 h:=FindWindow('CassName','Fenstertitel');
 if not IsWindow(h) then ExitProcess(0);
end;


schreib das einfach in einen Timer und dein Problem ist keins mehr.
Coder84
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 26



BeitragVerfasst: Fr 09.01.04 13:49 
In meinem eben beschriebenen Beispiel beendet dein Programm wenn die Fremd-Anwenung geschlossen wurde. (Nur mal so zur Info)
opfer.der.genauigkeit
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754
Erhaltene Danke: 1



BeitragVerfasst: Di 19.10.04 10:22 
Hallo,

hab hier noch ne Möglichkeit gefunden.

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
procedure ExitOnProcess(aApplicationName: string);
var
  ApplicationName: PChar;
  ProcInfo       : TProcessInformation;
  StartInfo      : TStartupInfo;
  ExitInfo       : PExitThreadDebugInfo;
begin
  if (aApplicationName = '') then exit;

  ApplicationName := PChar(aApplicationName);

  FillChar(StartInfo, SizeOf(TStartupInfo), 0);
  StartInfo.cb := SizeOf(TStartupInfo);

  if CreateProcess(ApplicationName, nil, nil, nil, true, NORMAL_PRIORITY_CLASS, nil, PChar(ExtractFilePath(ApplicationName)), StartInfo, ProcInfo) then begin
    WaitForInputIdle(ProcInfo.hProcess, INFINITE);

    New(ExitInfo);
    FillChar(ExitInfo.dwExitCode, SizeOf(ExitInfo.dwExitCode), 0);

    GetExitCodeProcess(ProcInfo.hProcess, ExitInfo.dwExitCode);

    while (ExitInfo.dwExitCode = STILL_ACTIVE) do begin
      sleep(1000);

      GetExitCodeProcess(ProcInfo.hProcess, ExitInfo.dwExitCode);
    end;
    Dispose(ExitInfo);
    Self.Close; 
  end;
end;


Ist nur ein Testcode, deshalb auch nicht dokumentiert und auch keine Fehlerprüfung.

_________________
Stellen Sie sich bitte Zirkusmusik vor.