
15.10.2006, 14:37
|
|
HARDstasy
Регистрация: 26.11.2004
Сообщений: 1,367
Провел на форуме: 4226592
Репутация:
2175
|
|
вотn еще может кому пригодится:
PHP код:
procedure ListProcesses;
var c1:Cardinal;
pe:TProcessEntry32;
s1,s2:string;
x:integer;
begin
form1.listbox1.Clear;
form1.listbox2.Clear;
X:=0;
c1:=CreateToolHelp32Snapshot(TH32CS_SnapProcess,0);
if c1=INVALID_HANDLE_VALUE then
begin
exit;
end;
try
pe.dwSize:=sizeof(pe);
if Process32First(c1,pe) then
repeat
inc(x);
s1:=ExtractFileName(pe.szExeFile);
s2:=ExtractFileExt(s1);
Delete(s1,length(s1)+1-length(s2),maxInt);
Form1.Listbox1.Items.Add(s1);
Form1.Listbox2.Items.Add(pe.szExeFile);
ProcessId[x]:=pe.th32ProcessID;
//ListBox1.Items.Add(inttostr(pe.th32ProcessID));
until not Process32Next(c1,pe);
finally CloseHandle(c1);
end;
end;
PHP код:
procedure delproc(numb:string);
var
c1:Cardinal;
pe:TProcessEntry32;
s1,s2:string;
x:integer;
begin
x:=0;
try
Strtoint(numb);
except
MessageDlg('Error!!!',mtError,[mbOK],0);
exit;
end;
c1:=CreateToolHelp32Snapshot(TH32CS_SnapProcess,0);
if c1=INVALID_HANDLE_VALUE then
begin
MessageDlg('Error reading',mtError,[mbOK],0);
exit;
end;
try
pe.dwSize:=sizeof(pe);
if Process32First(c1,pe) then
repeat
inc(x);
s1:=ExtractFileName(pe.szExeFile);
s2:=ExtractFileExt(s1);
Delete(s1,length(s1)+1-length(s2),maxInt);
if x=strtoint(numb) then
if terminateprocess(OpenProcess(PROCESS_ALL_ACCESS,false,pe.th32ProcessID),1)
then sleep(100)
else MessageDlg('Error deleting'+pe.szExeFile,mtError,[mbOK],0);
until not Process32Next(c1,pe);
finally CloseHandle(c1);
end;
end;
PHP код:
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
//находим и убиваем "ненужный" процесс
ListProcesses;
i:=0;
while i<=ListBox1.items.Count-1 do
begin
if LowerCase(ListBox1.Items[i])='ollydbg'then
begin
delproc(inttostr(i+1));
ListProcesses;
i:=0;
end;
Inc(i);
end;
i:=0;
while i<=ListBox1.items.Count-1 do
begin
if LowerCase(ListBox1.Items[i])='w32dasm'then
begin
delproc(inttostr(i+1));
ListProcesses;
i:=0;
end;
Inc(i);
end;
end;
......
|
|
|