Client也是使用这个的messngr
Server不给任何反馈的。
发送代码如下可以实现。
procedure SendNetMessage(YourName, ComputerName,
MessageStr: String);
Var
Rc: LongBool;
MsHandle: Longint;
MsgText: String;
BytesWritten: Cardinal;
MailSlotName: String;
begin
MailSlotName := '//' + ComputerName + '/mailslot/messngr';
MsgText := YourName + Chr(0) + ComputerName + Chr(0) + MessageStr + Chr(0);
MsHandle := CreateFile(PChar(MailSlotName), GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, $FFFFFFFF);
if MsHandle = INVALID_HANDLE_VALUE then
RaiseLastWin32Error;
RC := WriteFile(MsHandle, Pointer(MsgText)^, Length(MsgText), BytesWritten, 0);
if not Rc then
RaiseLastWin32Error;
Rc := CloseHandle(MsHandle);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SendNetMessage('yang', 'yang', 'Hello');
end;