WriteMsgQueue (Windows CE 5.0)

Send Feedback

This function writes a single message to a message queue.

BOOL WriteMsgQueue(HANDLEhMsgQ,LPVOIDlpBuffer,DWORDcbDataSize,DWORDdwTimeout,DWORDdwFlags);

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.
  • cbDataSize
    [in] Number of bytes stored in lpBuffer that comprise a message. This parameter cannot be 0 (zero).
  • dwTimeout
    [in] Amount of time, in milliseconds (ms), before the write operation will time out. If zero is specified, the write operation will not block if the write operation cannot succeed. If you set the parameter to INFINITE, the write operation will block until the write operation succeeds or the queue status changed.
  • dwFlags
    [in] DWORD value to indicate the properties of the message. You can set it to MSGQUEUE_MSGALERT to specify that the message is an alert message.

Return Values

Returns TRUE if the write operation succeeds; 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 size of lpBuffer is too large to hold a 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 writer will fail and GetLastError returns ERROR_PIPE_NOT_CONNECTED.

Note   The GetLastError function does not return ERROR_PIPE_NOT_CONNECTED if you specify MSGQUEUE_ALLOW_BROKEN and you 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.
ERROR_OUTOFMEMORY If you specify MSGQUEUE_NOPRECOMMIT, and there is not enough memory to allocate for the message.

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 | ReadMsgQueue

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.