Close
MSMQQueue

The Close method closes this instance of the queue.

Syntax

object.Close
 
Syntax Element Description
object Queue (MSMQQueue) object that represents the open instance of the queue.

Remarks

When this method succeeds, MSMQ sets Handle to INVALID_HANDLE_VALUE.

The MSMQQueue object still exists after Close is called. Use the MSMQQueue object's IsOpen property to test if the queue is opened or closed.

Example

This example opens a queue for sending messages, then closes the queue. To try this example using Microsoft® Visual Basic® (version 5.0), paste the code into the Code window of a form, and then run the example and click the form.

Dim qinfo As MSMQQueueInfo
Dim q As MSMQQueue

Private Sub Form_Click()
    
  Set qinfo = New MSMQQueueInfo
  qinfo.PathName = ".\CloseTest"
  qinfo.Label = "Test Queue"
  qinfo.Create
  
  Set q = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
   
  If q.IsOpen Then
     MsgBox "The " + qinfo.Label + " is open."
  Else
     MsgBox "The " + qinfo.Label + " is closed."
  End If
  
  q.Close
  
  If q.IsOpen Then
     MsgBox "The " + qinfo.Label + " is open."
  Else
     MsgBox "The " + qinfo.Label + " is closed."
  End If
   
End Sub 
 

See Also

Create, IsOpen, MSMQQueue, MSMQQueueInfo, Label, Open, PathName


© 1997 by Microsoft Corporation. All rights reserved.