📄 列表5.10.txt
字号:
【列表5.10】 KillerApp程序代码。
{
frmKiller - Demonstrate selective killing of instances of
a process by name
}
unit frmKiller;
interface
uses
SysUtils, Types, Classes, QGraphics, QControls, QForms, QOialogs,
QStdCtrls, Libc, ProcStuff;
type
TfrmKillerMain = class(TForm)
KillBtn: TButton;
ExitBtn: TButton;
Label1: TLabel;
Label2: TLabel;
procedure ExitBtnClick(Sender: TObject);
procedure KiltBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
LF = ^J; { ASCII linefeed/newline }
PROCESSNAME = 'CrashTestDummy';
var
frmKillerMain: TfrmKillerMain;
implementation
{SR *.xfm}
procedure TfrmKillerMain. ExitBtnClick(Sender: TObject);
begin
Close;
end;
procedure TfrmKillerMain. KillBtnClick(Sender: TObject);
var
i : Integer;
L : TList;
PRec : PProcInfoRec;
begin
L := GetProcessListByName(PROCESSNAME);
if L.Count > 0
then for i := 0 to L,Count - 1 do
begin
PRec := L.Items[i];
with PRec^ do
if MessageDlg('Kill Process '
'Process ' + IntToStr(i + 1) + ' of ' + IntToStr(L.Count)
+ LF + LF
+ 'Kill this process?' + LF + LF
+ 'Process ID: ' + IntToStr(PID) + LF
+ 'Status: ' + Status + LF
+ 'User name: ' + UName + LF
+ 'Command: ' + CmdName + LF,
mtConfirmation, [mbYes, mbNo], 0) =mrYes
then kill(PID, SIGTERM);
end { for }
else ShowMessage('No matches found for ' + PROCESSNAME);
L.Free;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -