Reset
MSMQQueue    MSMQQueueInfos

The Reset method returns the cursor to the start of the results of a query or to the start of a queue.

Syntax

object.Reset
 
Syntax Element Description
object Collection (MSMQQuery) object that represents a collection of queues, or queue (MSMQQueue) object that represents an open instance of a queue.

Return Codes

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

Remarks

Next Queue
When looking at the results of a query, the MSMQQueueInfos object's Reset method moves the cursor to the start of the query. To move to the first queue of the query, call Next.
Next Message
When looking at the messages in a queue, the MSMQQueue object's Reset method moves the cursor to the start of the queue. To move to the first message in the queue, call PeekCurrent or ReceiveCurrent.

Example: Pointing to the first queue

This example assumes that at least one queue whose label is "Test Queue" already exists. It runs a query for the test queues, then displays the format name of the first queue found.

To try this example using Microsoft® Visual Basic® (version 5.0), make sure the Microsoft Message Queue Object Library is referenced, paste the following code into the Code window of a form, run the example, and click the form.

Dim query As New MSMQQuery
Dim qinfos As MSMQQueueInfos
Dim qinfo As MSMQQueueInfo

Private Sub Form_Click()

   Set qinfos = query.LookupQueue(Label:="Test Queue")
   qinfos.Reset
   Set qinfo = qinfos.Next
   MsgBox "I found a Test Queue! its Format name is: " + FormatName
    
End Sub 
 

Example: Pointing to the first message

This example assumes that a queue exists, opens the queue for receiving messages, looks at the label of each message in the queue, and then resets the cursor to the start of the queue.

To try this example using Microsoft® Visual Basic® (version 5.0), make sure the Microsoft Message Queue Object Library is referenced, paste the following Code into the code window of a form, run the example, and click the form.

Dim qinfoMyQueue as MSMQQueueInfo
Dim qMyInputQueue as MSMQQueue
Dim msgMyMessage as MSMQMessage
 
'Open queue as an input queue (set Access to MQ_RECEIVE_ACCESS).
Set qMyInputQueue = qinfoMyQueue.Open (Access := MQ_RECEIVE_ACCESS, ShareMode := MQ_DENY_NONE)
Set msgMyMessage = qMyInputQueue.PeekCurrent
 
'Traverse queue.
While not msgMyMessage is Nothing
      set msgMyMessage = qMyInputQueue.PeekNext
      msgbox msgMyMessage.Label
Wend
 
qMyInputQueue.Reset                 'Points to start of queue.
 

QuickInfo

  Windows NT: Requires version 4.0 SP3 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in mqoai.h.
  Import Library: Use mqoa.lib.
  Unicode: Defined only as Unicode.

See Also

FormatName, Label, MSMQQuery, MSMQQueueInfo, MSMQQueueInfos, Next, Reset