uses Tlhelp32; function KillTask(ATask: string): Boolean; var Loop: Boolean; hd: THandle; pe: TProcessEntry32; begin Result := False; hd := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); pe.dwSize := Sizeof(pe); Loop := Process32First(hd,pe); while Loop do begin if ((UpperCase(ExtractFileName(pe.szExeFile)) = UpperCase(ATask)) or (UpperCase(pe.szExeFile) = UpperCase(ATask))) then Result := TerminateProcess(OpenProcess($0001,False,pe.th32ProcessID),0); Loop := Process32Next(hd,pe); end; CloseHandle(hd); end;
时间: 2024-10-13 16:15:15