Autor Beitrag
Littleboxer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

Windows 2000,

BeitragVerfasst: Sa 19.11.05 10:10 
moin moin :wink2:

ich hoffe ich bin im richtigen forum. wenn nicht bitte verschieben. war mir nicht sicher ob das in win api rein soll oder im datei forum. :oops:

nun aber zu meiner hoffentlich leichten frage: ich starte mit meinem programm ein anderes programm und warte mit WaitForSingleObject so lange ab bis sich das programm beendet hat. gibt es eine möglichkeit von meinem programm aus das andere Programm zu beenden? Es kann nämlich sein das sich das programm nicht mehr beendet werden kann. dann wäre es schön wenn man, so wie in Delphi mit STRG+F2, den Prozess beendet könnte.

danke für eure antworten.
KlausNeu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Sa 19.11.05 13:32 
Hallo Henning,

sowas hab ich mal gemacht, hier der code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
var h : hwnd;
begin
  h := FindWindow('notepad',nil);   // Notepad wird beendet
  if h <> 0 then SendMessage(h, WM_SYSCOMMAND, SC_CLOSE, 0);
end;


Schwierig ist es manchmal, den richtigen Namen fürs Programm zu finden, der InternetExplorer heißt anscheinend IEFrame. Wenn du den Programmnamen kennst, kannst du es ja einfach ausprobieren. Ansonsten gibts noch eine Funktion FindWindowByTitle, die die Fenster nach dem Titel sucht. Viel Spaß noch!

Klaus

Moderiert von user profile iconMotzi: Delphi-Tags hinzugefügt.
reepo2k
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 138

WIN XP
Borland Delphi 7 Enterprise, Microsoft Visual C++ 6.0 Enterprise, Macromedia Dreamweaver 8
BeitragVerfasst: Sa 19.11.05 13:40 
Hmm, das müsst mit der madCollection (www.madshi.net) ganz leicht gehen,
zumindest hab ich damit keine Probleme.

MfG: reepo2k
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 19.11.05 13:53 
1. haben wir eine Suchfunktion Suche in: Delphi-Forum, Delphi-Library PROZESS BEENDEN
2. Kann ich Dir die Schweizer empfehlen, die haben sowas nämlich in ihrer Tippssammlung auf www.swissdelphicenter.ch stehen
3. ist die madCollection kommerziell. Kostenlos und genauso wirksam ist, wenn Du's schon unbedingt über so 'ne Funktionssammlung machen willst, die uallCollection (Freeware mit Source).
4. So 'ne Kollektion ist overhead, da das eine Funktion von maximal 10-20 Zeilen ist. Such einfach mal!

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.