Autor Beitrag
Talbot
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

Win 2000, Win98, WinXP Prof, Linux(Suse, Gentoo, Debian, RedHat)
D6 Enterprise
BeitragVerfasst: Mo 15.03.04 15:29 
Aaaaalso.

hier im Forum gibts ja haufenweise Infos zum Beenden von Prozessen bei denen man das Windowhandle hat. Was aber mach ich wenn ich nen Prozess beenden will der nur im Hintergrund läuft?

Wo ich halt kein Fenster hab von dem ich den Windowhandle bekomm....

*ratlossei* :nixweiss:
Pascal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155

Win 98, Win XP
Delphi 2005, Delphi 5
BeitragVerfasst: Mo 15.03.04 17:34 
Du musst natürlich irgendwas über den Prozess wissen. Wenn du den Classname weist kannst du das Handle über findcomponent() rausfinden.

Wenn du den Exe-Pfad weißt dann geht das hier
Zitat:
Einen Task beenden


Diese Funktion beendet alle Tasks mit den gleichen EXE-Names.

ausblenden volle Höhe Delphi-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:
32:
33:
34:
35:
36:
uses Tlhelp32;

function KillTask(ExeFileName: string): integer; 
const 
  PROCESS_TERMINATE=$0001;
var 
  ContinueLoop: BOOL; 
  FSnapshotHandle: THandle; 
  FProcessEntry32: TProcessEntry32;
begin
  result := 0; 

  FSnapshotHandle := CreateToolhelp32Snapshot
                     (TH32CS_SNAPPROCESS, 0); 
  FProcessEntry32.dwSize := Sizeof(FProcessEntry32); 
  ContinueLoop := Process32First(FSnapshotHandle,
                                 FProcessEntry32); 

  while integer(ContinueLoop) <> 0 do
  begin 
    if ((UpperCase(ExtractFileName(
                       FProcessEntry32.szExeFile)) =
         UpperCase(ExeFileName)) or
       (UpperCase(FProcessEntry32.szExeFile) =
         UpperCase(ExeFileName))) then

      Result := Integer(TerminateProcess(OpenProcess(
                        PROCESS_TERMINATE, BOOL(0), 
                        FProcessEntry32.th32ProcessID), 0));

    ContinueLoop := Process32Next(FSnapshotHandle,
                                  FProcessEntry32); 
  end;

  CloseHandle(FSnapshotHandle);
end;

(Aus dem Easy-Delphi-Helper auf [url]www.delphi-treff.de[/url])

Moderiert von user profile iconMotzi: Delphi-Tags hinzugefügt.
Talbot Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

Win 2000, Win98, WinXP Prof, Linux(Suse, Gentoo, Debian, RedHat)
D6 Enterprise
BeitragVerfasst: Di 16.03.04 13:13 
Vielen Vielen Dank! :)