Windows Dev Center


(Introduced in MSMQ 3.0.) The MQMgmtGetInfo function retrieves information about a queue or the Message Queuing installation on a computer.

  LPCWSTR pMachineName,  
  LPCWSTR pObjectName,  
  MQMGMTPROPS * pMgmtProps       



[in] A pointer to a Unicode string that contains the name of a computer. The computer can be specified using its UNC, DNS, or IP address. The local computer can be specified by setting this parameter to NULL.


[in] A pointer to a Unicode string that describes the type of object:


Required when retrieving information about the queue manager.


Required when retrieving information about a queue.


[in, out] A pointer to an MQMGMTPROPS structure that specifies the properties to be retrieved.

On input, the cProps member of the structure specifies the number of properties specified, the aPropID array specifies the identifiers of the properties, and the elements of the aPropVar array must be set to VT_NULL.

On output, the elements of the aPropVar array contain the returned property values.

On output, no return codes are set in the aStatus array.

Return Values


Indicates success.

MQ_ERROR (0xC00E0001)

A non-specific Message Queuing error was generated. For example, information about a queue that is currently not the active queue was requested.


The access rights for retrieving information about the applicable msmq (MSMQ-Configuration) or queue object are not allowed for the calling process.


The specified format name in pObjectName is illegal.


An invalid type indicator was supplied for one of the properties specified in pMgmtProps.


The queue is not open or may not exist.


The Message Queuing service is not available.


An unsupported property identifier was specified in pMgmtProps.


This function is used to retrieve two distinct sets of properties. Use the following guidelines when making calls to this function:

  • If the pObjectName parameter specifies a computer, retrieve only those properties that start with PROPID_MGMT_MSMQ.

  • If the pObjectName parameter specifies a queue, retrieve only those properties that start with PROPID_MGMT_QUEUE.

These properties can be retrieved only for active queues.

The type indicator of each property specified must be set to VT_NULL. In this case, Message Queuing allocates the resources needed for the returned values. If it is not set to VT_NULL, the operation fails and an MQ_ERROR_ILLEGAL_PROPERTY_VT error is returned.

However, the application must call MQFreeMemory to free these resources after the returned values are not needed.

To retrieve information about a computer or a queue, the access rights for retrieving information about the applicable msmq (MSMQ-Configuration) or queue object must be allowed for the account under which the calling process is running. However, this requirement is ignored if the following registry entry is added.


If this entry is set to 1, only users that belong to the Local Administrators group are allowed to retrieve information about a computer or a queue using the MQMgmtGetInfo function.

The functionality of the local administration API functions introduced in MSMQ 3.0 (MQMgmtAction, MQMgmtGetInfo, and MQPurgeQueue) is also available for computers running previous versions of Message Queuing. For more information, see MSMQ Local Admin API.

Equivalent COM Method

The COM equivalents of MQMgmtGetInfo are MSMQApplication for machine objects and MSMQManagement for queue objects.

Example Code

The following code example is included in Using Message Queuing.

For an example of See

Retrieving a list of path names of all the private queues on a specified computer

C/C++ Code Example: Obtaining a List of Private Queues

Enumerating Subqueues

Subqueues under a given main queue can be enumerated by calling the MQMgmtGetInfo function. The management property PROPID_MGMT_QUEUE_SUBQUEUE_COUNT can be used to count the number of subqueues inside a given main queue. The management property PROPID_MGMT_QUEUE_SUBQUEUE_NAMES can be used to enumerate the list of names of all subqueues in a given main queue. The following sample code shows how to enumerate the subqueues in a main queue.

ULONG GetSubqueueInfo(const wstring& machineName, const wstring&,
    // Define the required constants and variables.
    const int NUMBEROFPROPERTIES = 2;  // Number of properties
    DWORD cPropId = 0;  // Property counter
    // Define an MQMGMTROPS structure.
    MQMGMTPROPS mgmtprops;
    // Retrieve the count of the subqueues.
    aMgmtPropVar[cPropId].vt = VT_NULL;                
    // Retrieve the names of the subqueues.
    aMgmtPropVar[cPropId].vt = VT_NULL;                
    // Initialize the MQMGMTPROPS structure.
    mgmtprops.cProp = cPropId;   // number of management properties
    mgmtprops.aPropID = aMgmtPropId;// management property IDs
    mgmtprops.aPropVar = aMgmtPropVar;// management property values
    mgmtprops.aStatus  = NULL;// no storage for error codes

    wstring objectName = L"QUEUE=" + formatName;
    HRESULT hr = MQMgmtGetInfo(machineName.c_str(), 
            objectName.c_str(), &mgmtprops);
    ULONG subqueueCount = aMgmtPropVar[0].lVal;
    wcout << L"Subqueue count is " << subqueueCount << endl;

    ULONG nameCount = aMgmtPropVar[1].calpwstr.cElems;
        wcout << L"Subqueue name count is " << nameCount << endl;
    wcout << L"Subqueue list: ";
    for(int i=0; i < nameCount; i++)
        wcout << aMgmtPropVar[1].calpwstr.pElems[i] << L" ";
    wcout << endl;
    // Free the memory allocated to store the subqueue names.
    for (int i = 0; i < aMgmtPropVar[1].calpwstr.cElems; i++)
    return subqueueCount;


Windows NT/2000/XP: Included in Windows XP and Windows Server 2003.

Windows 95/98/Me: Unsupported.

Header: Declared in Mq.h.

Library: Use Mqrt.lib.

See Also

© 2015 Microsoft