The ShareMode property indicates the share mode of the queue.
Type: | Long |
Run time: | read-only |
object.ShareMode
Syntax Element | Description |
---|---|
object | Queue (MSMQQueue) object that represents the open instance of the queue. |
The ShareMode property returns one of the following values:
The ShareMode property returns the share mode of the queue when it was last opened, regardless if the queue is currently opened or closed.
When ShareMode returns MQ_DENY_NONE, several users can be using the queue at the same time.
This example opens a queue for sending messages, and uses the value of ShareMode to test who can use the queue (with what share mode). 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 = ".\lShareModeTest"
qinfo.Label = "Test Queue"
qinfo.Create
Set q = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
Select Case q.ShareMode
Case MQ_DENY_NONE
MsgBox "The queue is open for multiple users."
Case MQ_DENY_RECEIVE_SHARE
MsgBox "The queue is only open for this process."
Case Else
MsgBox "Not a valid return value!"
End Select
q.Close
End Sub
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.
Close, Create, Label, MSMQQueue, MSMQQueueInfo, Open, PathName