TreminateProcessByName('f:/qq.exe');<br><br><br>//------------------------------------------------------------------------------<br>function TreminateProcessByName(Const ExeFile:string):Boolean;<br>var<br> p: TProcessInfo;<br> ContinueLoop: Boolean;<br> FSnapshotHandle: THandle;<br> FProcessEntry32: TProcessEntry32;<br> hh: HWND;<br>begin<br> Result:=False;<br> FSnapshotHandle := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br> try<br> FProcessEntry32.dwSize := SizeOf(FProcessEntry32);<br> ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);<br> while integer(ContinueLoop) <> 0 do<br> begin<br> if fcISNT then<br> begin<br> hh := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, FProcessEntry32.th32ProcessID);<br> if hh <> 0 then<br> begin<br> if GetModuleFileNameEx(hh, 0,FProcessEntry32.szExeFile,SizeOf(FProcessEntry32.szExeFile)) = 0 then<br> begin<br> StrPCopy(FProcessEntry32.szExeFile, '[Idle]');<br> end;<br> CloseHandle(hh);<br> end;<br> end;<br><br> p.ExeFile := FProcessEntry32.szExeFile;<br><br> if lowercase(p.ExeFile)=lowercase(ExeFile) then<br> begin<br> p.ProcessID := FProcessEntry32.th32ProcessID;<br> hh := OpenProcess(PROCESS_ALL_ACCESS, true, p.ProcessID);<br> try<br> TerminateProcess(hh, 0);<br> Application.MessageBox('QQ禁止在本机运行,请与管理员联系!', '禁止运行',MB_ICONINFORMATION + MB_OK);<br> finally<br> CloseHandle(hh);<br> end;<br> end;<br> ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);<br> end;<br> finally<br> CloseHandle(FSnapshotHandle);<br> end;<br>end;