ShareMode
MSMQQueue

The ShareMode property indicates the share mode of the queue.

Type: Long
Run time: read-only

Syntax

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

Return Values

The ShareMode property returns 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

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
 

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

Close, Create, Label, MSMQQueue, MSMQQueueInfo, Open, PathName