Handle
MSMQQueue

Read-only. The Handle property indicates the handle of the opened queue.

Type: Long
Run time: read-only

Syntax

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

Return Values

Queue handle.

Remarks

This handle refers to this instance of the queue. The value of Handle changes each time a queue is opened.

After the queue is closed, MSMQ sets Handle to INVALID_HANDLE_VALUE.

Handle can be used to call MSMQ API functions directly. For example, when using Microsoft® Visual Basic®, MSMQ functions can be called directly using the Declare Function facility.

Example

This example opens a queue for sending messages, and then uses the value of Handle to test if the queue is open. 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 = ".\Handle"
  qinfo.Label = "Test Queue"
  qinfo.Create
  
  Set q = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
   
  If q.Handle = INVALID_HANDLE_VALUE Then
     MsgBox "The queue is closed"
  Else
     MsgBox "The queue is open. Handle is: " + CStr(q.Handle)
  End If
 
End Sub
 

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

Create, Label, MSMQueue, MSMQQueueInfo, Open, PathName