共用方式為


PROPID_MGMT_MSMQ_ACTIVEQUEUES

 

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_MGMT_MSMQ_ACTIVEQUEUES property returns a list of the active queues on the computer.

Property ID

PROPID_MGMT_MSMQ_ACTIVEQUEUES

Type Indicator

VT_LPWSTR | VT_VECTOR

MQPROPVARIANT Field

calpwstr

Property Value

A counted array of pointers to strings containing the format names of all the active queues on the computer.

Remarks

Active queues include the following:

  • Any public and private queues that contain messages.

  • Any queue for which an application has a handle open (or had a handle recently).

  • Outgoing queues (temporary internal queues holding messages for remote destination queues).

To retrieve a list of the active queues on a computer, include PROPID_MGMT_MSMQ_ACTIVEQUEUES in the MQMGMTPROPS structure, and then call MQMgmtGetInfo.

When specifying PROPID_MGMT_MSMQ_ACTIVEQUEUES in the MQMGMTPROPS structure, set its type indicator to VT_NULL. During the function call, Message Queuing automatically changes the type indicator to VT_LPWSTR | VT_VECTOR and creates the buffers needed to receive the property values. The number of active queues found is returned in the cElems member of the calpwstr field of the applicable MQPROPVARIANT element in the property values array, and the format names are returned in the array of strings specified by the pElems member of the calpwstr field. After you no longer need the array of strings, you must free the memory allocated for it using MQFreeMemory.

The outgoing queues included in the list of active queues on a specific computer returned in PROPID_MGMT_MSMQ_ACTIVEQUEUES can be identified by obtaining the value of PROPID_MGMT_QUEUE_LOCATION for each queue in the list. Because the format name of an outgoing queue is a format name of the corresponding destination queue, the value of PROPID_MGMT_QUEUE_LOCATION returned for an active outgoing queue residing on the computer specified in the call to MQMgmtGetInfo will refer to the destination queue residing on a different computer and will be MGMT_QUEUE_REMOTE_LOCATION.

Equivalent COM Property

When using COM components, you can retrieve a list of the active queues on a computer using the MSMQApplication.ActiveQueues property.

Example Code

The following code fragment shows how PROPID_MGMT_MSMQ_ACTIVEQUEUES is specified in arrays that can be used to initialize an MQMGMTPROPS structure for retrieving a list of the active queues on a computer.

aMgmtPropID[i] = PROPID_MGMT_MSMQ_ACTIVEQUEUES;         // Property identifier  
aMgmtPropVar[i].vt = VT_NULL;                           // Type indicator  
i++;  

The following code fragment shows how to free the memory allocated for the list of active queues retrieved.

for (j = 0; j < aMgmtPropVar[i].calpwstr.cElems; j++)  
{  
    MQFreeMemory(aMgmtPropVar[i].calpwstr.pElems[j]);  //Free each element  
}  
MQFreeMemory(aMgmtPropVar[i].calpwstr.pElems);         //Free the array  

See Also

Management Properties
MQFreeMemory
MQMgmtGetInfo
MSMQApplication.ActiveQueues
PROPID_MGMT_QUEUE_LOCATION