?? 列表6.6.txt
字號:
【列表6.6】摘錄自PipeReadMain.pas的程序代碼。
procedure TPipeReadMainForm. RunPSBtnClick(Sender: TObject);
const
LF = ^J; { ASCII linefeed/newline }
READ_IOMode : 'r'; { read mode from pipe }
var
CmdArr : array[0..512] of char;
StrArr : array[0..1024] of char;
F : PIOFile;
pPipeStr : Pointer;
s : String;
begin
psMemo.Clear;
{ Set up to run the ps command }
StrCopy(CmdArr, 'ps');
if ParamCombo.ItemIndex > 0
then begin
{ Add a selected parameter }
s :=' ', + ParamCombo. Items[ParamCombo. ItemIndex];
StrPCopy(StrArr, s);
StrCat(CmdArr, StrArr);
end;
{ Open a pipe for reading from ps's output }
F := popen(CmdArr, READ_IOMode);
if assigned(F)
then begin
repeat
{ Read a complete line from the ps output stream }
pPipeStr := fgets(StrArr, 1024, F);
if Assigned(pPipeStr)
then begin
s := StrPas(pPipeStr);
if pos(LF, s) > 0 then delete(s, pos(LF, s), 1);
psMemo. Lines.Add(s);
end;
until not Assigned(pPipeStr);
{ Close the pipe - don't try to catch errors }
pclose(F);
end;
end;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -