Compartilhar via


WriteMsgQueue

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

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 when 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. There can be only one outstanding alert message in the queue, so this value is treated as a hint. 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.

> [!NOTE] > The GetLastError function does not return this value if you specified MSGQUEUE_ALLOW_BROKEN when you created the queue and you write a message for which there is no reader attached to the queue.

ERROR_TIMEOUT

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

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

Reference

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

Other Resources

Message Queue Point-to-Point