The ShareMode property of the MSMQQueue object indicates the share mode in which the queue was opened.

Data type:


Run-time access:


Property ShareMode As Long

Property Value

A Long set to one of the following values:


The queue is available to everyone for sending, peeking, or retrieving messages. This is always returned if the queue is opened with Access set to MQ_PEEK_ACCESS or MQ_SEND_ACCESS.


Messages can only be retrieved by this process. This value is only returned if the queue is opened with Access set to MQ_RECEIVE_ACCESS.


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.

Example Code

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 or 6.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"
  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."
          MsgBox "The queue is only open for this process."
     Case Else
          MsgBox "The value returned is not a valid return value!"
  End Select
End Sub


Windows NT/2000/XP: Included in Windows NT 4.0 SP3 and later.

Windows 95/98/Me: Included in Windows 95 and later.

Header: Declared in Mqoai.h.

Library: Use Mqoa.lib.

See Also

© 2014 Microsoft