function TNetF.SendNetMess(ToMess:PChar;TextMess: PChar):Boolean; var hSlot: HWND; buf : array[0..100]of char; cb: DWORD; FromMess: array[0..20]of char; begin CharToOem(TextMess,TextMess); CharToOem(ToMess,ToMess); FromMess:='Администратор сети'+#0; CharToOem(FromMess,FromMess); Result:=False; hSlot:= CreateFile(PChar(ToMess+'\mailslot\messngr'), GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,0); if hSlot <> INVALID_HANDLE_VALUE then begin cb:=0; StrECopy(StrECopy(StrECopy(buf,FromMess)+1,ToMess)+1, TextMess); //1. From cb:=cb+StrLen(FromMess)+1; //2. To cb:=cb+StrLen(ToMess)+1; //3. Само сообщение // CharToOem(buf, buf); cb:=cb+StrLen(TextMess)+1; Result:=WriteFile(hSlot, buf, cb, cb, nil); CloseHandle(hSlot); end; end; |