列表5.18.txt
来自「klinux书籍的配套光盘。可以学习学习。」· 文本 代码 · 共 32 行
TXT
32 行
【列表5.18】帮助函数 ProcReadLink和调用他的函数。
// ProcReadLink - return the name of the file that the
// link points to.
function ProcReadLink (pid: __pid_t; const sFile: String): String;
var
buf : array [0..1024] of char;
iLen : Integer;
sFilename : String;
begin
sFilename := Format ('/proc/%d/%s', [pid, sFile]);
iLen := readlink (PChar(sFilename), buf, 1024);
if iLen = -1 then
iLen := 0;
buf[iLen] := #0;
Result := buf;
end;
// ProcGetCwd - return the process's current working directory.
function ProcGetCwd (pid: __pid_t): String;
begin
Result := ProcReadLink (pid, 'cwd');
end;
// ProcGetExe - return the name of the process's executable.
function ProcGetExe (pid: __pid_t): String;
begin
Result := ProcReadLink (pid, 'exe');
end;
// ProcGetRoot - return the process's root directory
function ProcGetRoot (pid: __pid_t): String;
begin
Result := ProcReadLink (pid, 'root');
end;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?