TTimer加KillProcess达到禁止程序运行

uses TlHelp32

Function KillProcess2(TheProcName:String):boolean; //杀死进程(根据进程名)   

KillProcess2('isqlw.exe');
KillProcess2('mmc.exe');

 

Function KillProcess2(TheProcName:String):boolean; //杀死进程(根据进程名)
var 
    isOK:Boolean;
    ProcessHandle:Thandle;
    ProcessStruct:TProcessEntry32;
begin
     ProcessHandle:=createtoolhelp32snapshot(Th32cs_snapprocess,0);
     processStruct.dwSize:=sizeof(ProcessStruct);
     isOK:=process32first(ProcessHandle,ProcessStruct);
     while isOK do
     begin  
  if TheProcName=ProcessStruct.szExeFile then
         begin
            Result:=KillProcess(ProcessStruct.th32ProcessID);
            CloseHandle(ProcessHandle);
            exit;
         end; 
  isOK:=process32next(ProcessHandle,ProcessStruct);
     end;
     CloseHandle(ProcessHandle);
end;

你可能感兴趣的:(process)