Optional. The PrivLevel property specifies the privacy level of a queue or message.
For queues, this property specifies whether the queue accepts private (encrypted) messages, non-private messages, or both.
For messages, this property specifies whether the message is private (encrypted).
Type: | Long |
Run time: | read/write |
object.PrivLevel
Syntax Element | Description |
---|---|
object | For queues, the queue information (MSMQQueueInfo) object that defines the queue. For messages, the message (MSMQMessage) object that defines the message. |
For queues, set PrivLevel to one of the following values:
For messages, set PrivLevel to one of the following values:
To specify the privacy level when creating the queue, set PrivLevel and call the MSMQQueueInfo object's Create method.
To reset the privacy level of a queue after the queue is created, set PrivLevel to a new level, and if the queue is open, call the MSMQQueueInfo object's Update method. If the queue is not open, do not call Update because the queue's properties are updated automatically when the queue is opened.
To find out the privacy level of a queue, call the MSMQQueueInfo object's Refresh method.
When encrypting and decrypting messages, MSMQ uses the algorithm specified in EncryptAlgorithm.
For a complete example of sending a private message (including setting the privacy level of a queue), see Sending Private Messages.
This example creates a private queue on the local computer, setting the queue's privacy level to MQ_PRIV_LEVEL_OPTIONAL. 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
Private Sub Form_Click()
Set qinfo = New MSMQQueueInfo
qinfo.PathName = ".\PRIVATE$\PrivacyLevelTest"
qinfo.Label = "Test Queue"
qinfo.PrivLevel = MQ_PRIV_LEVEL_OPTIONAL
qinfo.Create
MsgBox "Queue's Format name is: " + qinfo.FormatName
End Sub
This example opens a queue that can only accept private messages, and then sends a private message to the queue.
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
Dim msg As New MSMQMessage
Private Sub Form_Click()
'**********************
' Create queue
'**********************
Set qinfo = New MSMQQueueInfo
qinfo.PathName = ".\PrivacyTest"
qinfo.Label = "Test Queue"
qinfo.PrivLevel = MQ_PRIV_LEVEL_BODY
qinfo.Create
'*********************
' Open queue.
'*********************
Set q = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
'*********************
' Send message.
'*********************
msg.Label = "Test Message"
msg.Body = "This is a private message."
msg.PrivLevel = MQMSG_PRIV_LEVEL_BODY
msg.Send q
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.
Body, Create, Label, MSMQMessage, MSMQQueue, MSMQQueueInfo, Open, PathName, Refresh, Send, Update