DOCERR: CreateFile() and Mailslots

Last reviewed: January 26, 1996
Article ID: Q131493
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT version 3.5
    

SUMMARY

The documentation for CreateFile() API gives incorrect possible return values while opening a client end of a mailslot. The documentation states:

    If CreateFile opens the client end of a mailslot, the function always
    returns a valid handle, even if the mailslot does not exist.
    In other words, there is no relationship between opening the client
    end and opening the server end of the mailslot.

Actually, CreateFile() returns INVALID_HANDLE_VALUE for a mailslot if the mailslot client is being created using the "\\." notation to communicate with a mailslot server on the local system when the server is not up and running.

MORE INFORMATION

The following code always returns INVALID_HANDLE_VALUE for a handle value from CreateFile() while opening the client end of the mailslot if the mailslot server is not up and running to read mailslot messages:

    CreateFile("\\\\.\\mailslot\\testslot",
               GENERIC_WRITE,
               FILE_SHARE_READ,
               NULL,
               OPEN_EXISTING,
               FILE_ATTRIBUTE_NORMAL,
               NULL);

GetLastError() in this case returns Error 2: "The system cannot find the specified file."

This is an expected behavior. Windows NT implementation of local mailslots does not allow you to open the mailslot if the receiver has not created the server end with CreateMailslot() API.


Additional reference words: 3.50
KBCategory: kbprg kbnetwork kbdocerr
KBSubcategory: BseIpc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 26, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.