Habe ich noch nicht mit mehreren Rechnern getestet.
Code: Alles auswählen
;-Top
; Kommentar : MailSlot
; Author : mk-soft
; Erstellt am : 18.03.2006
; Geändert am : 08.08.2006
Global *buffer
*buffer = AllocateMemory(2048)
; ---------------------------------------------------------
Procedure.l MakeSlot(Name.s)
ProcedureReturn CreateMailslot_("\\.\mailslot\" + Name, 2048, #MAILSLOT_WAIT_FOREVER, #Null)
EndProcedure
; ---------------------------------------------------------
Procedure ReadSlot(hSlot.l)
result = GetMailslotInfo_(hSlot, @lpMaxMessageSize, @lpNextSize.l, @lpMessageCount.l, 0)
If result <> 0
If lpNextSize >= 0
ReadFile_(hSlot, *buffer, lpNextSize, @lpNumberOfBytesRead, 0)
AddGadgetItem(0, -1, PeekS(*buffer,lpNumberOfBytesRead))
EndIf
EndIf
EndProcedure
; ---------------------------------------------------------
Procedure WriteSlot(Von.s, Text.s)
Name.s = StringField(text, 1, " ")
Send.s = Von + ": " + Right(text, Len(text) - Len(name) - 1)
If OpenFile(0, "\\*\mailslot\" + Name)
WriteString(0, Send)
CloseFile(0)
EndIf
EndProcedure
; ---------------------------------------------------------
handle = 0
Name.s = InputRequester("Startup MailSlot", "Dein Name", "Name")
If Name = ""
End
EndIf
If OpenWindow(0,20,20,300,200,"MailSlot - " + Name)
CreateGadgetList(WindowID(0))
ListViewGadget(0, 0, 0, 300, 170)
StringGadget(1, 4, 172, 290, 24, "Name Nachricht")
handle = MakeSlot(Name)
If handle = #INVALID_HANDLE_VALUE
Debug "Fehler beim anlegen von Mail Slot"
End
EndIf
AddKeyboardShortcut(0, #PB_Shortcut_Return, 13)
SetActiveGadget(1)
exit = 0
Repeat
event = WindowEvent()
gadget = EventGadget()
type = EventType()
menu = EventMenu()
ReadSlot(handle)
Select event
Case #PB_Event_CloseWindow
CloseHandle_(handle)
exit = 1
Case #PB_Event_Menu
If menu = 13
WriteSlot(Name, GetGadgetText(1))
SetGadgetText(1, "")
EndIf
Case 0
Delay(10)
EndSelect
Until exit
EndIf

Update PB4
- Name im Fenstertitel