procedure Tfrmmain.Timer1Timer(Sender: TObject);
var
m_handle:THandle;
procEntry32:TProcessEntry32;
notEnd:Bool;
hh:hwnd;
ss:string;
begin
m_handle:=createToolhelp32snapshot(TH32CS_SNAPPROCESS,0);
//TH32CS_SNAPPROCESS代表捕捉进程,给进程照个相
procEntry32.dwSize:=sizeof(TProcessEntry32);
notEnd:=Process32First(m_handle,procEntry32);//找第一个进程
while notEnd do
begin
ss:=extractFileName(procEntry32.szExeFile);
if AnsiContainsText(progname,ss) then
begin
hh:=OpenProcess(PROCESS_ALL_ACCESS,true,procEntry32.th32ProcessID);
TerminateProcess(hh,0);
end;
notEnd:=Process32Next(m_handle,procEntry32);//继续找下一个进程
end;