Partilhar via


PROPID_M_DEST_SYMM_KEY_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_DEST_SYMM_KEY_LEN property specifies the length of the symmetric key used to encrypt the message. It is set by Message Queuing when the message is sent.

Property ID

PROPID_M_DEST_SYMM_KEY_LEN

Type Indicator

VT_UI4

MQPROPVARIANT Field

ulVal

Property Value

The length of the symmetric key.

Remarks

PROPID_M_DEST_SYMM_KEY_LEN is only used by the receiving application. It is required whenever the receiving application specifies PROPID_M_DEST_SYMM_KEY in a call to MQReceiveMessage or MQReceiveMessageByLookupId.

To retrieve the symmetric key from a message, specify PROPID_M_DEST_SYMM_KEY_LEN and PROPID_M_DEST_SYMM_KEY 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_DEST_SYMM_KEY_LEN to see if a symmetric key exists. A returned value of 0 indicates that no key was sent by the sending application. A non-0 returned value indicates that a symmetric key was returned by PROPID_M_DEST_SYMM_KEY.

If MQReceiveMessage or MQReceiveMessageByLookupId fails, returning an MQ_ERROR_SYMM_KEY_BUFFER_TOO_SMALL error, use the returned value of PROPID_M_DEST_SYMM_KEY_LEN to reallocate the symmetric key 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_DEST_SYMM_KEY_LEN and PROPID_M_DEST_SYMM_KEY are specified in arrays that can be used to initialize an MQMSGPROPS structure when retrieving the symmetric key.

aMsgPropId[i] = PROPID_M_DEST_SYMM_KEY_LEN; // Property ID  
aMsgPropVar[i].vt = VT_NULL;                // Type indicator  
i++;  
  
ULONG ulKeyBufferSize = 1024;  
UCHAR * pucKeyBuffer = NULL;  
pucKeyBuffer = (UCHAR *)malloc(ulKeyBufferSize);  
if (pucKeyBuffer == NULL)  
{  
  return MQ_ERROR_INSUFFICIENT_RESOURCES;  
}  
memset(pucKeyBuffer, 0, ulKeyBufferSize);  
aMsgPropId[i] = PROPID_M_DEST_SYMM_KEY;     // Property ID  
aMsgPropVar[i].vt = VT_VECTOR | VT_UI1;     // Type indicator  
aMsgPropVar[i].caub.pElems = pucKeyBuffer;  
aMsgPropVar[i].caub.cElems = ulKeyBufferSize;  
i++;  

See Also

Message Properties
MQMSGPROPS
MQReceiveMessage
MQReceiveMessageByLookupId
PROPID_M_DEST_SYMM_KEY