Using MailSlots to communicate between apps.

Share your advanced PureBasic knowledge/code with the community.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Using MailSlots to communicate between apps.

Post by Flype »

sorry if it has already be done,

i'm testing mailslots to send/receive datas from an app to another.

here is little archive if you want to test (free to use) :

MailSlot.zip
Image

More infos here on MSDN :
http://msdn2.microsoft.com/en-us/library/aa365147.aspx
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

updated.
Declare.l MailSlot_WriteString(hSlot.l, string.s) ; Writes a string to the given mailslot.
Declare.l MailSlot_WriteData(hSlot.l, *MemoryBuffer, LengthToWrite.l) ; Writes the content of the specified memory buffer to the given mailslot.
Declare.s MailSlot_ReadString(hSlot.l) ; Reads a string from the given mailslot.
Declare.l MailSlot_ReadData(hSlot.l, *MemoryBuffer, LengthToRead.l) ; Reads the content from the given mailslot inside the specified memory buffer.
Declare.l MailSlot_Open(SlotName.s) ; Open an existing mailslot, must be closed using CloseSlot().
Declare.l MailSlot_Next(hSlot.l) ; Returns #True if there are one or more messages in the given mailslot.
Declare.s MailSlot_LastError() ; Returns a formatted string of the last error.
Declare.l MailSlot_Create(SlotName.s) ; Creates a mailslot, must be closed using CloseSlot().
Declare.l MailSlot_Close(hSlot.l) ; Close an existing mailslot.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Chrono Syndrome
Enthusiast
Enthusiast
Posts: 169
Joined: Thu Oct 05, 2006 6:44 am
Contact:

Post by Chrono Syndrome »

Good job.
Don't try to catch ze Night !
Remember: 'z' is better zen 'th' =) !
Sorry for bad english.
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

This is pretty usefull. Thanks Flype!
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

Seems to be a hot topic lately :-)

Mailslots work well, they're just limited to 400+ bytes I believe, but that should be enough for many cases.

Gonna have a look at it myself later :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

Doing a search on the boards indeed showed a few cases, but that isn't going to stop us, is it? :-)

http://www.purebasic.fr/english/viewtop ... 997#198997
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

nice example, you learn fast :wink:
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

:-)

Actually, I did not even use your sample, I admit I had a look at it, but as I'm not into libraries I decided to figure it out on my own the best way I could, by bumbling and stumbling around :-)

I didn't test yet the 'multiple mailslot' thing, can multiple programs have the same mailslot open? Documentation was a bit conclicting on that one. Did you look into that?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply