WindowsXP/2000/net下的方法
Console命令:taskkill /pid 进程ID
可以写成
procedure killproc(PID:dword);
begin
Winexec(pchar('taskkill /PID '+inttostr(pid)), sw_hide);
end;
Console命令:taskkill /pid 进程ID
可以写成
procedure killproc(PID:dword);
begin
Winexec(pchar('taskkill /PID '+inttostr(pid)), sw_hide);
end;
去看看吧 或许对你有帮助
uses tlhelp32;procedure TForm1.Button2Click(Sender: TObject);
var
hSnapshot: Integer;
bFound: Boolean;
ProcessEntry: ProcessEntry32;
begin
hSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if hSnapshot = 0 then Exit;
bFound := Process32First(hSnapshot, ProcessEntry);
while bFound do
begin
if LowerCase(ExtractFileExt(ProcessEntry.szExeFile)) = '.exe' then
with ListView1.Items.Add do
begin
Caption := ProcessEntry.szExeFile;
SubItems.Add(IntToStr(ProcessEntry.th32ProcessID));
end;
bFound := Process32Next(hSnapshot, ProcessEntry);
end;
CloseHandle(hSnapshot);
end;procedure TForm1.Button3Click(Sender: TObject);
var
iProcessId: Integer;
hProcess: Integer;
begin
if ListView1.Selected <> nil then
begin
iProcessId := StrToInt(ListView1.Selected.SubItems[0]);
hProcess := OpenProcess(PROCESS_ALL_ACCESS, false, iProcessId);
if hProcess <> 0 then
TerminateProcess(hProcess, 0);
end;
end;