procedure TMyslotServerThread.Execute;
var
mailslot, nb:cardinal;
buf:PChar;
s:string;
begin
mailslot:=CreateMailslot(PChar('\\.\Mailslot\Myslot'), 100,
MAILSLOT_WAIT_FOREVER, nil);
If mailslot=INVALID_HANDLE_VALUE then
begin
ShowMessage('Error slot');
exit;
end;
buf:=StrAlloc(120);
FillChar(buf^, 120, #0);
While (not Terminated) do
begin
ReadFile(mailslot, buf^, 120, nb, nil);
If nb<>0 then
begin
s:=string(buf);
If s='close' then
break;
FOwner.Spisok.Add(s);
Synchronize(ToSpisok);
end;
FillChar(buf^, 120, #0);
end;
StrDispose(buf);
CloseHandle(mailslot);
end;
procedure TMyslotClientThread.Execute;
var
mailslot, nb:cardinal;
buf:PChar;
i:Integer;
begin
mailslot:=CreateFile(PChar(FAdress), GENERIC_WRITE, FILE_SHARE_READ, nil,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
If mailslot=INVALID_HANDLE_VALUE then
begin
ShowMessage('Error clientslot');
exit;
end;
buf:=StrAlloc(Length(FMsg)+1);
FillChar(buf^, Length(FMsg), #0);
StrPCopy(buf, FMsg);
For i:=1 to FCount do
begin
If Terminated then
break;
WriteFile(mailslot, buf^, Length(FMsg)+1, nb, nil);
Sleep(10);
end;
StrDispose(buf);
CloseHandle(mailslot);
end;