Share via


MSMQQueue.ShareMode

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

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

Data type: Long
Run-time access: Read-only
Property ShareMode As Long  

Property Value

A Long set to one of the following values:

MQ_DENY_NONE

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.

MQ_DENY_RECEIVE_SHARE

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.

Remarks

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"  
  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 "The value returned is not a valid return value!"  
  End Select  
  
  q.Close  
  
End Sub  

Requirements

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

MSMQQueue
MSMQQueue.Close
MSMQQueueInfo
MSMQQueueInfo.Create
MSMQQueueInfo.Label
MSMQQueueInfo.Open
MSMQQueueInfo.PathName