PROPID_M_SENDERID_LEN

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

(Read-only.) The PROPID_M_SENDERID_LEN property indicates the length of the sender identifier.

Property ID

PROPID_M_SENDERID_LEN

Type Indicator

VT_UI4

MQPROPVARIANT Field

ulVal

Property Value

Length (in bytes) of the sender identifier.

Remarks

PROPID_M_SENDERID_LEN is used only by the receiving application when calling MQReceiveMessage or MQReceiveMessageByLookupId. Message Queuing attaches this property to the message when it attaches PROPID_M_SENDERID.

To retrieve the sender identifier from a message, set PROPID_M_SENDERID_LEN and PROPID_M_SENDERID in the MQMSGPROPS structure. Then call MQReceiveMessage or MQReceiveMessageByLookupId and examine the returned values. The type indicator of this property can be set to VT_UI4 or VT_NULL. If you set the type indicator to VT_NULL, Message Queuing automatically changes the type indicator to VT_UI4 during the function call.

When the function call succeeds, first test the returned value of PROPID_M_SENDERID_LEN to see if a sender identifier exists. A returned value of 0 indicates that a sender identifier was not included in the message. A non-0 return value indicates that a sender identifier was returned by PROPID_M_SENDERID.

If MQReceiveMessage or MQReceiveMessageByLookupId fails, returning an MQ_ERROR_SENDERID_BUFFER_TOO_SMALL error, use the returned value of PROPID_M_SENDERID_LEN to reallocate the sender identifier buffer and call the applicable function again.

Equivalent COM Property

This property is not needed when you are using COM components.

Example Code

The following code fragment shows how PROPID_M_SENDERID_LEN and PROPID_M_SENDERID are specified in arrays that can be used to initialize an MQMSGPROPS structure when retrieving the sender identifier.

ULONG ulSenderIdBufferSize = 256;  
UCHAR *pucSenderIdBuffer = (UCHAR *)malloc(ulSenderIdBufferSize);  
if (pucSenderIdBuffer == NULL)  
{  
  return MQ_ERROR_INSUFFICIENT_RESOURCES;  
}  
memset(pucSenderIdBuffer, 0, ulSenderIdBufferSize);  
aMsgPropId[i] = PROPID_M_SENDERID_LEN;      // Property ID  
aMsgPropVar[i].vt = VT_NULL;                // Type indicator  
i++;  
  
aMsgPropId[i] = PROPID_M_SENDERID;          // Property ID  
aMsgPropVar[i].vt = VT_VECTOR | VT_UI1;     // Type indicator  
aMsgPropVar[i].caub.pElems = pucSenderIdBuffer;  
aMsgPropVar[i].caub.cElems = ulSenderIdBufferSize;  
i++;  

The following example is included in Using Message Queuing.

For an example of See
Retrieving the sender identifier from authenticated messages C/C++ Code Example: Validating Authentication

See Also

Message Properties
MQMSGPROPS
MQReceiveMessage
MQReceiveMessageByLookupId
MQSendMessage
PROPID_M_SENDERID
PROPID_M_SENDERID_TYPE