Could someone report here two simple programs such that:

The first:

----------------------------------------------------------------------------------

Creates a mailslot with CreateMailslot(),as this

Code:
HANDLE hMail = CreateMailSlot("\\\\.\\mailslot\hello",0,15000,NULL);
then it sleeps for some time for letting the second program to be
opened in time , before this one tries to get a message from the mailslot

Code:
Sleep(5000);
and at this time it looks for messages in the mailslot

Code:
....please tell me how to do it
--------------------------------------------------------------------------------

The second :

-------------------------------------------------------------------------------

Opens the mailslot and puts a message on it

Code:
...how could i do?...
--------------------------------------------------------------------------------

I tried doing this

In the first program,for getting a message:

-------------------------------------------------------------------------------

Use GetMailslotInfo() for obtaining the size of the next message

Open,for a read operation,the mailslot with CreateFile(),
obtaining another handle to the mailslot,but that has read access to it , for reading messages

and then use ReadFile() telling him to read as many bytes as the
size of the message

-----------------------------------------------------------------------------

it doesn't work...

perhaps i had not to use CreateFile() but just ReadFile with the
handle to the mailslot (hMail) ???


In the second program,for putting messages:

------------------------------------------------------------------------------

Code:
HANDLE hFile = CreateFile("\\\\.\\mailslot\\hello",GENERIC_WRITE,
                                          0,NULL,OPEN_EXISTING,
                                          FILE_ATTRIBUTE_NORMAL,NULL);

use hFile in WriteFile() and write some bytes
------------------------------------------------------------------------------

is it correct ??

Please try writing here these two programs , for example
the second program could send a string "hello" to the first
and the first reads it in a buffer and visualizes it in MessageBox()

thank u in advance