列表5.14.txt
来自「klinux书籍的配套光盘。可以学习学习。」· 文本 代码 · 共 33 行
TXT
33 行
【列表5.14】枚举进程。
procedure EnumProcesses (cb : TProcEnumCallback);
var
sr : TSearchRec;
findRslt : Integer;
pid : __pid_t;
begin
findRslt := FindFirst ('/proc/*', faDirectory or faAnyFile, sr);
try
while findRslt =0 do
begin
if ((sr.Attr and faDirectory) <> 0) then
begin
{
Try to convert directory name to an integer.
If it fails, we know it isn't a process ID.
}
try
pid := StrToInt (sr. Name);
except
// not a process ID, so set to -1
pid := -1;
end;
if pid >= 0 then
cb (pid);
end;
findRslt := FindNext (sr);
end;
finally
FindClose (sr);
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?