次の方法で共有


PROPID_M_LABEL_LEN (Compact 2013)

3/26/2014

This property identifies the length (in Unicode characters) of the message label buffer.

  • Type Indicator
    VT_UI4
  • PROPVARIANT Field
    ulVal
  • Property Values
    On input, the size (in Unicode characters) of the message label buffer allocated by the receiving application.

    On return, the length (in Unicode characters) of the label string plus the end-of-string character.

Remarks

PROPID_M_LABEL_LEN is only used by the receiving application. It is required when PROPID_M_LABEL is specified in the MQMSGPROPS structure.

On input, the message label buffer should be large enough to hold the complete label string including the end-of-string character.

MQReceiveMessage succeeds if the buffer is large enough to hold the message label. If the buffer is too small, MQReceiveMessage fails and PROPID_M_LABEL_LEN can be used to obtain the required buffer length of the message label string.

To retrieve the label of a message, specify PROPID_M_LABEL_LEN and PROPID_M_LABEL in the MQMSGPROPS structure. Then call MQReceiveMessage and examine the returned values.

When MQReceiveMessage succeeds, test the returned value of PROPID_M_LABEL_LEN to see if a message label exists.

A returned value of 0 indicates that no label was specified by the sending application.

A nonzero returned value indicates that the label was returned by PROPID_M_LABEL.

If MQReceiveMessage fails, returning an MQ_ERROR_BUFFER_TOO_SMALL error, use the returned value of PROPID_M_LABEL_LENto reallocate the message label buffer and call MQReceiveMessage again.

When retrieving the label of several messages, reset the value of PROPID_M_LABEL_LEN to the maximum label size allowed by MSMQ (250 Unicode characters) before retrieving the next label. If it is not reset, an error is returned if the new label is longer than the previous label.

This property is not needed when you use COM components.

Examples

This example shows how PROPID_M_LABEL_LENis specified in the MQMSGPROPS structure when retrieving the message label.

aMsgPropId[i] = PROPID_M_LABEL_LEN;        // Property ID
aMsgPropVar[i].vt =VT_UI4;                 // Type indicator
aMsgPropVar[i].ulVal = 250;                // Label buffer size
i++;
aMsgPropId[i] = PROPID_M_LABEL;            // Property ID
aMsgPropVar[i].vt = VT_LPWSTR;             // Type indicator
aMsgPropVar[i].pwszVal = wszLabelBuffer;   // Label buffer
i++;

Note

OS versions prior to 2.12 require the MSMQ add-on pack.

Requirements

Header

mq.h

See Also

Reference

MSMQ Properties
MQReceiveMessage
PROPID_M_LABEL
MQMSGPROPS