unit3.pas
来自「DELPHI与其它进程通信」· PAS 代码 · 共 55 行
PAS
55 行
unit Unit3;
interface
uses Classes,forms, Sysutils, Windows, ShellAPI;
type
TServerThread = class (TThread)
private
m_Name :string;
FCount:integer;
FPipe: Cardinal;
public
procedure Execute;
end;
implementation
procedure TServerThread.Execute;
Var fConnected, fSuccess: LongBool;
chRequest: String[55];
chReply: String;
lb: Byte absolute chRequest;
dwThreadID, cbBytesRead,
cbReplyBytes, cbWritten: DWord;
FullPipeName: String;
sValue: String;
Advise: String;
Data: String;
Name, Machine, ExtData: String;
Const PName :PChar = '\\.\pipe\';
begin
m_Name := 'MyPipe1';
FCount := 0;
fConnected := FALSE;
FullPipeName := PName + m_Name;
while TRUE do begin
// Named Pipe erzeugen
FPipe := CreateNamedPipe( PChar(FullPipeName),
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_Message or PIPE_READMODE_Byte or PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES, 225, 255,
NMPWAIT_USE_DEFAULT_WAIT, NIL);
if(FPipe <> INVALID_HANDLE_VALUE)then
fConnected := ConnectNamedPipe(FPipe, nil);
if (fConnected) then begin
if(DisconnectNamedPipe(FPipe))then CloseHandle(FPipe);
if(Application.Terminated = TRUE)then Exit;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?