Read-only. The Handle property indicates the handle of the opened queue.
Type: | Long |
Run time: | read-only |
object.Handle
Syntax Element | Description |
object | Queue (MSMQQueue) object that represents the open instance of the queue. |
Queue handle.
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.
This example opens a queue for sending messages, 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, 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 = ".\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
Create, Label, MSMQueue, MSMQQueueInfo, Open, PathName