Updated: July 19, 2016

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

The Next method of the MSMQQueueInfos object, which represents a query, returns an MSMQQueueInfo object that represents the next queue in the collection of public queues satisfying the search criteria of the query.

Function Next() As MSMQQueueInfo  

This method has no parameters.

An MSMQQueueInfo object that represents a single public queue in the collection of public queues satisfying the search criteria of the query (in C++, a smart pointer to the IMSMQQueueInfo interface).

For information on return codes, see Message Queuing Error and Information Codes.

The MSMQQueueInfos object is created and initialized by a call to the MSMQQuery.LookupQueue method.

The application must call Next to point the cursor to the first queue in the collection of public queues that satisfy the search criteria of the query, and then retrieve the properties of the first queue. After the cursor is pointing at the first queue, Next can be called repeatedly to enumerate all the remaining elements of the collection.

Next returns Null if there are no queues in the collection or the cursor is at the end of the collection (EOL).

The following code fragment displays the path names of all the public queues with a specific service type GUID.

Dim query as New MSMQQuery  
Dim qinfos as MSMQQueueInfos  
Dim qinfoCurrent as MSMQQueueInfo  
Set qinfos = query.LookupQueue( _  
Set qinfoCurrent = qinfos.Next  
While Not qinfoCurrent Is Nothing  
    MsgBox qinfoCurrent.PathName  
    Set qinfoCurrent = qinfos.Next  

The following example is included in Using Message Queuing.

For an example ofSee
Locating a set of public queues based on the queue labelC++ COM Code Example: Locating a Queue

 Visual Basic Code Example: Locating a Queue

Windows NT/2000/XP: Included in Windows NT 4.0 SP3 and later.

Windows 95/98/Me: Included in Windows 95 and later.

Header: Declared in Mqoai.h.

Library: Use Mqoa.lib.