?? 列表6.9.txt
字號:
【列表6.9】摘錄自PipeChildMain.pas的程序代碼。
const
StrIndexLen = 4;
LF = ^J; { ASCII linefeed/newline }
var
PipeChildMainForm: TPipeChildMainForm;
ParentReadPipe : Integer;
SigActionRec : TSigAction;
implementation
{SR *.xfm}
procedure Handler(Sig : Integer); cdecl;
begin
case Sig of
SIGUSR1 : PipeChildMainForm. ReadPipe;
end; { case }
end;
procedure InstallHandler;
with SigActionRec do
begin
sigaction_handler := Handler;
sigemptyset(sa_mask);
sa_flags :=0;
sigaction(SIGUSR1, @SigActionRec, nil);
end; { with }
end;
procedure TPipeChildMainForm. ReadPipe;
var
ReadBuf : array[0..BUFSIZ] of Char;
s : String;
len : Integer;
begin
{ Get the length of the string }
_read(ParentReadPipe, ReadBuf, StrIndexLen);
ReadBuf[StrIndexLen] := chr(0);
len := StrToInt(ReadBuf);
{ Get the string }
read(ParentReadPipe, ReadBuf, len);
ReadBuf[len] := chr(0);
s := ReadBuf;
MsgMemo,Lines.Add(s);
end;
procedure TPipeChildMainForm. FormCreate(Sender: TObject);
begin
InstallHandler;
ParentReadPipe := StrToInt(ParamStr(1));
end;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -