次の方法で共有


ReadMsgQueue (Compact 2013)

3/28/2014

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 DWORD to 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 lpBuffer is too small to read a message. The read operation succeeded, but only cbBufferSize bytes 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 dwTimeout parameter was set to zero, and there was no data to read.

Requirements

Header

msgqueue.h

Library

coredll.lib

See Also

Reference

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