klinux书籍的配套光盘。可以学习学习。

源代码在线查看: 列表5.18.txt

软件大小: 62 K
上传用户: villyc
关键词: klinux 书籍 光盘
下载地址: 免注册下载 普通下载 VIP

相关代码

				【列表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;
							

相关资源