Autor Beitrag
F.Art
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 434



BeitragVerfasst: Di 25.05.04 03:28 
Ich möchte nach einem bestimmten Task suchen lassen. Sobald dieser Task vorhanden ist soll er was ausführen. Wie mache ich das?


Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Di 22.06.2004 um 09:31
FaTaLGuiLLoTiNe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 5

Windows 7, Windows 8.1
Delphi XE
BeitragVerfasst: Di 25.05.04 07:37 
Der richtige Suchbegriff in diesem Fall wäre Suche in: Delphi-Forum, Delphi-Library ENUMPROCESSES

// edit:nur Rechtschreibung

_________________
<< FaTaLGuiLLoTiNe >>
Rhinoceroses don't play games!


Zuletzt bearbeitet von FaTaLGuiLLoTiNe am Di 25.05.04 11:58, insgesamt 1-mal bearbeitet
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 25.05.04 09:44 

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
F.Art Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 434



BeitragVerfasst: Di 25.05.04 10:53 
Ich habe mal nach den Begriffen gesucht, aber leider nichts passendes gefunden was ich verstehen würde. Kann mir einer mal eine Quelltext geben?
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 25.05.04 11:05 
F.Art Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 434



BeitragVerfasst: Di 25.05.04 12:37 
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:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, TLHelp32, PsAPI;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function TerminateEXE(sFile: string): Bool;
var verSystem: TOSVersionInfo; hdlSnap,hdlProcess: THandle; bPath,bLoop: Bool;
    peEntry: TProcessEntry32; arrPid: array [0..1023] of DWord; iC: DWord;
    i,iCount: Integer; arrModul: array [0..299] of Char; hdlModul: HMODULE;
begin
 result:=false; 
 if ExtractFileName(sFile)=sFile then bPath:=false else bPath:=true; 
 verSystem.dwOSVersionInfoSize:=SizeOf(TOSVersionInfo); 
 GetVersionEx(verSystem);
 if verSystem.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS then begin 
  hdlSnap:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); 
  peEntry.dwSize:=Sizeof(peEntry); 
  bLoop:=Process32First(hdlSnap,peEntry); 
  while integer(bLoop)<>0 do begin 
   if bPath then begin
    if CompareText(peEntry.szExeFile,sFile)=0 then begin 
     TerminateProcess(OpenProcess(PROCESS_TERMINATE,false,peEntry.th32ProcessID),0); 
     result:=true; 
    end; 
   end else begin 
    if CompareText(ExtractFileName(peEntry.szExeFile),sFile)=0 then begin 
     TerminateProcess(OpenProcess(PROCESS_TERMINATE,false,peEntry.th32ProcessID),0);
     result:=true; 
    end; 
   end; 
   bLoop:=Process32Next(hdlSnap,peEntry); 
  end; 
  CloseHandle(hdlSnap); 
 end else
 if verSystem.dwPlatformId=VER_PLATFORM_WIN32_NT then begin 
  EnumProcesses(@arrPid,SizeOf(arrPid),iC); 
  iCount:=iC div SizeOf(DWORD); 
  for i:=0 to Pred(iCount) do begin 
   hdlProcess:=OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,false,arrPid[i]); 
   if (hdlProcess<>0) then begin 
    EnumProcessModules(hdlProcess,@hdlModul,SizeOf(hdlModul),iC);
    GetModuleFilenameEx(hdlProcess,hdlModul,arrModul,SizeOf(arrModul)); 
    if bPath then begin 
     if CompareText(arrModul,sFile)=0 then begin 
      TerminateProcess(OpenProcess(PROCESS_TERMINATE or PROCESS_QUERY_INFORMATION,False,arrPid[i]), 0); 
      result:=true; 
     end; 
    end else begin
     if CompareText(ExtractFileName(arrModul),sFile)=0 then begin 
      TerminateProcess(OpenProcess(PROCESS_TERMINATE or PROCESS_QUERY_INFORMATION,False,arrPid[i]), 0); 
      result:=true; 
     end; 
    end; 
    CloseHandle(hdlProcess); 
   end;
  end; 
 end; 
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
 if TerminateEXE('notepad.exe') then ShowMessage('Anwendung beendet.');
end;

end.


Ich habe diesen QuellCode gefunden. Kann man die funktion nicht umändern so das er sucht und nicht killt?