Partager via


WriteMsgQueue (Compact 2013)

3/28/2014

This function writes a single message to a message queue.

Syntax

BOOL WriteMsgQueue(
  HANDLE hMsgQ,
  LPVOID lpBuffer,
  DWORD cbDataSize,
  DWORD dwTimeout,
  DWORD dwFlags
);

Parameters

  • hMsgQ
    [in] Handle to an open message queue.
  • lpBuffer
    [in] Pointer to a buffer that contains data to write to a message queue. This parameter cannot be NULL.
  • dwTimeout
    [in] Amount of time, in milliseconds, before the write operation times out. If zero is specified, the write operation does not block if the write operation cannot be performed. If you set the parameter to INFINITE, the write operation blocks until the write operation succeeds or the queue status changed.
  • cbDataSize
    [in] Number of bytes stored in lpBuffer that comprise a message. This parameter cannot be zero.
  • dwFlags
    [in] DWORD value to indicate the properties of the message.

    Set this parameter to MSGQUEUE_MSGALERT to specify that the message is an alert message. This is a hint because there can be only one outstanding alert message in the queue. If there is already an alert message in the queue, this flag is ignored, and the message is added to the queue as a normal message at the end of the queue.

    This parameter can be set to zero or NULL.

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 size of lpBuffer was too small to hold a message.

ERROR_OUTOFMEMORY

MSGQUEUE_NOPRECOMMIT was specified, and there was not enough memory to allocate for the message.

ERROR_PIPE_NOT_CONNECTED

Indicates that there are no readers attached to the message queue.

If all of the readers exit while the writer is blocked and you did not specify MSGQUEUE_ALLOW_BROKEN, the write operation fails, and GetLastError returns this value.

Ee488786.note(en-us,WinEmbedded.80).gifNote:
The GetLastError function does not return this value if you specify MSGQUEUE_ALLOW_BROKEN and write a message for which there is no reader to the queue.

ERROR_TIMEOUT

The write operation timed out before it could write its data.

Requirements

Header

msgqueue.h

Library

coredll.lib

See Also

Reference

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