Compartilhar via


ReadMsgQueue (Windows CE 5.0)

Send Feedback

This function reads a single message from a message queue.

BOOL ReadMsgQueue(HANDLEhMsgQ,LPVOIDlpBuffer,DWORDcbBufferSize,LPDWORDlpNumberOfBytesRead,DWORDdwTimeout,DWORD* pdwFlags);

Parameters

  • hMsgQ
    [in] Handle to an open message queue.
  • lpBuffer
    [out] Pointer to a buffer to store a read message. This parameter cannot be NULL.
  • cbBufferSize
    [in] Size of the buffer, in bytes, specified by lpBuffer. This parameter cannot be 0 (zero).
  • lpNumberOfBytesRead
    [out] Number of bytes stored in lpBuffer. This parameter cannot be NULL.
  • dwTimeout
    [in] Time in milliseconds (ms) before the read operation times out. If set to zero, the read operation will not block if there is no data to read. If set to INFINITE, the read operation will block until data is available or the status of the queue changes.
  • pdwFlags
    [out] Pointer to a DWORD to indicate the properties of the message. A value of MSGQUEUE_MSGALERT specifies that the message is an alert message.

Return Values

If the read operation succeeds, returns TRUE; otherwise, returns FALSE. To obtain extended error information, call the GetLastError function. The following table shows return values for the GetLastError function.

Value Description
ERROR_INSUFFICIENT_BUFFER The buffer specified by lpBuffer is too small to read a message. The read will succeed but only cbBufferSize bytes of data will be copied.
ERROR_PIPE_NOT_CONNECTED No writers are attached to the message queue and MSGQUEUE_ALLOW_BROKEN is not specified. All the writers exit while a reader is blocked and MSGQUEUE_ALLOW_BROKEN is not specified, the read will fail.
ERROR_TIMEOUT dwTimeout is zero and there is no data to read.

Requirements

OS Versions: Windows CE .NET 4.0 and later.
Header: Msgqueue.h.
Link Library: Coredll.lib.

See Also

Message Queue Point-to-Point | CloseMsgQueue | CreateMsgQueue | GetMsgQueueInfo | MSGQUEUEINFO | MSGQUEUEOPTIONS | OpenMsgQueue | WriteMsgQueue

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.