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, 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 
 
 

QuickInfo

  Windows NT: Requires version 4.0 SP3 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in resapi.h.

See Also

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