共用方式為


PROPID_M_DEST_FORMAT_NAME_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, introduced in MSMQ 3.0.) The PROPID_M_DEST_FORMAT_NAME_LEN property indicates the length (in Unicode characters) of the format name buffer allocated by the receiving application and the length of the format name string returned in PROPID_M_DEST_FORMAT_NAME.

Property ID

PROPID_M_DEST_FORMAT_NAME_LEN

Type Indicator

VT_UI4

MQPROPVARIANT Field

ulVal

Property Value

On input: The length of the format name buffer (in Unicode characters) allocated by the receiving application.

On return: The length (in Unicode characters) of the format name string (including the null-terminating character) returned in PROPID_M_DEST_FORMAT_NAME.

Remarks

The PROPID_M_DEST_FORMAT_NAME_LEN property is only used by the receiving application to reallocate a buffer for the destination queue set when the initially allocated buffer is too small. The queue manager of the source computer sets the destination properties of the message when the message is sent.

To retrieve the destination set, include the following two message properties in the MQMSGPROPS structure and then call MQReceiveMessage or MQReceiveMessageByLookupId.

If MQReceiveMessage or MQReceiveMessageByLookupId, returning an MQ_ERROR_FORMATNAME_BUFFER_TOO_SMALL error, use the returned value of PROPID_M_DEST_FORMAT_NAME_LEN to reallocate the buffer, and call the applicable function again.

Equivalent COM Property

There is no equivalent COM property for this property.

Example Code

The following code fragment shows how PROPID_M_DEST_FORMAT_NAME and PROPID_M_DEST_FORMAT_NAME_LEN are specified in arrays that can be used to initialize an MQMSGPROPS structure for retrieving the destination queue set.

ULONG ulBufferLength = 256;  
WCHAR * wszDestBuffer = NULL;  
wszDestBuffer = (WCHAR*)malloc(ulBufferLength*sizeof(WCHAR));  
if (wszDestBuffer == NULL)  
{  
  return MQ_ERROR_INSUFFICIENT_RESOURCES;  
}  
memset(wszDestBuffer, 0, ulBufferLength*sizeof(WCHAR));  
aMsgPropId[i] = PROPID_M_DEST_FORMAT_NAME_LEN;   // Property ID  
aMsgPropVar[i].vt = VT_UI4;                      // Type indicator  
aMsgPropVar[i].ulVal = ulBufferLength;  
i++;  
  
aMsgPropId[i] = PROPID_M_DEST_FORMAT_NAME;       // Property ID  
aMsgPropVar[i].vt = VT_LPWSTR;                   // Type indicator  
aMsgPropVar[i].pwszVal = wszDestBuffer;          // Application-defined buffer  
i++;  

The following example is included in Using Message Queuing.

For an example of See
Retrieving the destination format name and reallocating memory for the destination format name buffer when creating a response message C/C++ Code Example: Returning Response Messages

See Also

Message Properties
MQMSGPROPS
MQReceiveMessage
MQReceiveMessageByLookupId
PROPID_M_DEST_FORMAT_NAME