Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function reads a single message from a message queue.

Syntax

BOOL ReadMsgQueue(
  HANDLE 
hMsgQ,
  LPVOID 
lpBuffer,
  DWORD 
cbBufferSize,
  LPDWORD 
lpNumberOfBytesRead,
  DWORD 
dwTimeout,
  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 DWORDto indicate the properties of the message. A value of MSGQUEUE_MSGALERT specifies that the message is an alert message.

Return Value

TRUE indicates success. FALSE indicates failure. To obtain extended error information, call GetLastError. The following table shows possible values returned by GetLastError.

Value Description

ERROR_INSUFFICIENT_BUFFER

The buffer specified by lpBufferis too small to read a message. The read operation succeeded, but only cbBufferSizebytes of data were copied.

ERROR_PIPE_NOT_CONNECTED

No writers were attached to the message queue, and MSGQUEUE_ALLOW_BROKEN was not specified. All the writers exited while a reader was blocked, and MSGQUEUE_ALLOW_BROKEN was not specified. The read operation failed.

ERROR_TIMEOUT

The dwTimeoutparameter was set to zero, and there was no data to read.

Requirements

Header msgqueue.h
Library coredll.lib
Windows Embedded CE Windows CE .NET 4.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also