
29.03.2009, 01:11
|
Прохожий
|
|
Регистрация: 25.11.2008
Сообщения: 34
Репутация: 10
|
|
Что бы было понятно, что мне нужно провернуть скидываю код...
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, TLHelp32, PsAPI, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
Button2: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure GetProcessList(var sl: TStrings);
var
pe: TProcessEntry32;
ph, snap: THandle;
mh: hmodule;
procs: array[0..$FFF] of dword;
count, cm: cardinal;
i: integer;
ModName: array[0..max_path] of char;
begin
sl.Clear;
if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then
begin
snap := CreateToolhelp32Snapshot(th32cs_snapprocess, 0);
if integer(snap) = -1 then
begin
exit;
end
else
begin
pe.dwSize := sizeof(pe);
if Process32First(snap, pe) then
repeat
sl.Add(string(pe.szExeFile));
until not Process32Next(snap, pe);
end;
end
else
begin
if not EnumProcesses(@procs, sizeof(procs), count) then
begin
exit;
end;
for i := 0 to count div 4 - 1 do
begin
ph := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,
false, procs[i]);
if ph > 0 then
begin
EnumProcessModules(ph, @mh, 4, cm);
GetModuleFileNameEx(ph, mh, ModName, sizeof(ModName));
sl.Add(string(ModName));
CloseHandle(ph);
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
tmp: TStrings;
begin
tmp := Memo1.Lines;
GetProcessList(tmp);
end;
procedure TForm1.Button2Click(Sender: TObject);
Var List: TStringList;
Index: Integer;
begin
List := TStringList.Create;
List.Text := Memo1.Text;
List.Sort;
Memo1.Text := List.text;
if List.Find('chrome',Index) then ShowMessage('Найдено в строках '+IntToStr(Index));
end;
end.
ну а в ТХТ фале хранятся имена програм, которые нужно найти...
|