Autor Beitrag
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 03.10.02 11:44 
Hi !!

mit prcoess.terminate kann man ja fremde proggis killen, wenn man deren fensterhandle hat, richtig ??

So, ich check aber nicht, wie ich die funktion aufrufen muss.
als ersten parameter muss man ja das handle übergeben.

aber was ist bitte dieseer zweite parameter ?? die OH ist mir in diesem Fall keine grosse hilfe, da versteh ich nur bahnhof....

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 03.10.02 13:51 
Ich kenne nur TerminateProcess. Und da brauchst du als ersten Parameter nicht das Fensterhandle, sondern das Prozesshandle. Und der zweite Parameter ist der Exitcode.

TerminateProcess - MSDN
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 03.10.02 15:54 
uuups... stimmt :autsch:

@ luckie: auf der seite steht genau dasselbe wie in der online hilfe bzw. in der windows SDK hilfe. und den Text durchblick ich nicht wirklich...... :?

Gibts denn keine andre möglichkeit ein fenster bzw. eine anwendung zu killen oder wie kann ich eine app mit TerminateProcess killen, wenn ich nur das fensterhandle habe ??

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 03.10.02 16:00 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var
  hWnd: cardinal;
  ProcID: DWORD;
begin
  hWnd := FindWindow(nil, 'Unbenannt - Editor');
  GetWindowThreadProcessID(hWnd, @ProcID);
  TermianteProcess(ProcID, 0);
end;


Wenn du das Hauptfenster kennst, kannst du auch ein WM_DESTROY an das Fenster mit SendMessage schicken.


Zuletzt bearbeitet von Luckie am Do 03.10.02 16:23, insgesamt 1-mal bearbeitet
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 03.10.02 16:22 
danke !!!

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 03.10.02 16:24 
Du bist aber auch in der falschen Sparte. Das gehört nach Windows API.
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 03.10.02 16:26 
stimmt !!! sorry !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 03.10.02 18:51 
Luckie hat folgendes geschrieben:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var
  hWnd: cardinal;
  ProcID: DWORD;
begin
  hWnd := FindWindow(nil, 'Unbenannt - Editor');
  GetWindowThreadProcessID(hWnd, @ProcID);
  TermianteProcess(ProcID, 0);
end;


Wenn du das Hauptfenster kennst, kannst du auch ein WM_DESTROY an das Fenster mit SendMessage schicken.


Das kommt sicher nicht oft vor, dass dir jemand widersprechen muss, aber an dieser Stelle ist es wohl notwendig.

TerminateProcess benötigt nämlich nicht die ProcessID sondern ein Process-Handle und das besorgt man sich über OpenProcess (nicht vergessen das Handle mit CloseHandle wieder zu schließen) wobei man PROCESS_TERMINATE Zugriff haben muss (nur unter NT/2000 wichtig).

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 03.10.02 18:59 
Ups, da habe ich was durcheinander geschmissen. :oops:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var 
  hWnd, hProc: cardinal; 
  ProcID: DWORD; 
begin 
  hWnd := FindWindow(nil, 'Unbenannt - Editor'); 
  GetWindowThreadProcessID(hWnd, @ProcID); 
  hProc := OpenProcess(PROCESS_TERMINATE, FALSE, ProcID);
  TermianteProcess(hProc, 0); 
  CloseHandle(hProc);
end;


Ich habe es ja noch richtig geschrieben:
Zitat:

Ich kenne nur TerminateProcess. Und da brauchst du als ersten Parameter nicht das Fensterhandle, sondern das Prozesshandle.
:?
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 03.10.02 19:02 
danke @ all !!!

ich werde es erstmal mit WM_DESTROY versuchen. Das ist nämlich einfacher in meine Code einzubauen als der andre Code.

Was hat TerminateProcess denn für einen vorteil gegenüber WM_destroy ??

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 03.10.02 19:05 
Na, wenn du nicht das Hauptfenster erwischt, schließt du zwar das Fenster, aber das Programm läuft noch weiter.
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 03.10.02 19:11 
aha....

ich benutze den code von mathiassimmack (topic: Kann mir mal jemadn mit dem code helfen). da der code ja sowieso alle sichtbaren fenster durchkaut, ist die warscheinlichkeit äusserst gering, oder ?

_________________
In the beginning was the word.
And the word was content-type: text/plain.