次の方法で共有


PROPID_M_LABEL (Compact 2013)

3/26/2014

This property specifies a label of the message.

  • Type Indicator
    VT_LPWSTR
  • PROPVARIANT Field
    pwszVal
  • Property Values
    Arbitrary string (the default is none). The maximum length is 250 Unicode characters, including the end-of-string character.

Remarks

If the sending application specifies a message label longer than 250 Unicode characters, MSMQ returns an MQ_ERROR_LABEL_TOO_LONG error to the aStatus array.

To add a label to a message, specify PROPID_M_LABEL in the MQMSGPROPS structure and call MQSendMessage.

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.

Before using the returned value, inspect the returned value of PROPID_M_LABEL_LEN to see if the sending application specified a message label.

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.

Examples

The following examples show how PROPID_M_LABEL is specified in the MQMSGPROPS structure for setting and retrieving the message label.

To send a message label

aMsgPropId[i] = PROPID_M_LABEL;            // PropId
aMsgPropVar[i].vt = VT_LPWSTR;             // Type
aMsgPropVar[i].pwszVal = L"Test Message";  // Value
i++;

To retrieve 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
MQSendMessage
PROPID_M_LABEL_LEN
MQMSGPROPS