Required. The PathName property specifies the MSMQ pathname of the queue. The MSMQ pathname specifies the name of the computer where the queue's messages are stored, if the queue is public or private, and the name of the queue.
Type: | String |
Run time: | read/write |
object.PathName
Syntax Element | Description |
---|---|
object | Queue information (MSMQQueueInfo) object that defines the queue. |
String. The maximum length for the complete MSMQ pathname is MQ_MAX_Q_NAME_LEN (124 Unicode characters).
The PathName property is the only property required when calling the MQQueueInfo object's Create method. An MQ_ERROR_PROPERTY_NOTALLOWED error is returned if any attempt is made to set this property after the queue is created.
For public queues, PathName includes the name of the computer where the queue's messages are stored, followed by the name of the queue (the MSMQ pathname of public queues is stored in the Active Directory name space). For private queues, add \PRIVATE$\ between the machine name of the local computer and the queue name (private queues can only be registered on the local computer). For a description of public and private queues, see Message Queues.
Here are three examples of MSMQ pathnames. The first two examples indicate two public queues (one on a local computer and the other on a remote computer), and the third example indicates a private queue.
"myMachine\myPublicQueue"
"otherMachine\otherPublicQueue"
"myMachine\Private$\myPrivateQueue"
As a shortcut, you can substitute a period "." for the local machine. So myPublicQueue and myPrivateQueue could be specified on the local machine as:
".\myPublicQueue"
".\Private$\myPrivateQueue"
Public queues are registered in Active Directory, and private queues are registered on the local computer. Both types of queues exist until deleted explicitly.
Private queues are only created on the local computer. It is the application's responsibility to ensure that all queue names on the local computer are unique. If a queue name already exists when Create is called, MSMQ returns an MQ_ERROR_QUEUE_EXISTS error to the application.
To find out the MSMQ pathname of a queue, call the MSMQQueueInfo object's Refresh method.
Foreign public queues (queues located outside the enterprise) are created in the same way as an MSMQ public queue. For foreign queues, the PathName property specifies the name of the foreign computer as it is defined in Active Directory. For information on foreign computers, see MSMQ Connector Server.
This example creates a private queue on the local computer, setting the queue's label to "Test 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
Private Sub Form_Click()
Set qinfo = New MSMQQueueInfo
qinfo.PathName = ".\PRIVATE$\myqueue"
qinfo.Label = "Test Queue"
qinfo.Create
MsgBox "Queue's Format name is: " + qinfo.FormatName
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.
Create, FormatName, Label, MSMQQueueInfo