Public queues can be located by running a query on the queues registered in MQIS. A query can be based on the queue's identifier, its label, the type of service it provides, when it was created, or the last time the queue's properties were modified.
A query is made by calling the MSMQQuery object's LookupQueue method. When the query is finished, the returned MSMQQueueInfos object references all the queues located by the query.
Set qinfos = query.LookupQueue(Label:="Test Queue")
qinfos.Reset
Set qinfo = qinfos.Next While Not qinfo Is Nothing MsgBox "I found a Test Queue! its Format name is: " + qinfo.FormatName Set qinfo = qinfos.Next Wend
This example assumes that at least one queue whose label is "Test Queue" already exists. It runs a query for the test queues, displaying the format name of each queue it finds.
To try this example using Microsoft® Visual Basic® (version 5.0), paste the code into the Declaration section of a form, and then run the example and click the form.
Dim query As New MSMQQuery Dim qinfos As MSMQQueueInfos Dim qinfo As MSMQQueueInfo Dim Response As String Private Sub Form_Click() Set qinfos = query.LookupQueue(Label:="Test Queue") qinfos.Reset Set qinfo = qinfos.Next While Not qinfo Is Nothing MsgBox "I found a Test Queue! its Format name is: " + qinfo.FormatName Set qinfo = qinfos.Next Wend End Sub