PathName
MSMQQueueInfo

Required. The PathName property specifies the MSMQ pathname of the queue. The MSMQ pathname specifies the name of the computer where the queue's message are stored, if the queue is public or private, and the name of the queue.

Quick Info

Type: String
Run time: read/write

Syntax

object.PathName
 
Syntax Element Description
object Queue information (MSMQQueueInfo) object that defines the queue.

Settings

String. The maximum length for the complete MSMQ pathname is MQ_MAX_Q_NAME_LEN (124 Unicode characters).

Remarks

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 MQIS 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 MQIS, 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 MSMQ 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 MQIS. For information on foreign computers, see MSMQ Connector Server.

Example

This example creates a private queue on the local machine, 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, and then 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
 

See Also

Create, FormatName, Label, MSMQQueueInfo


© 1997 by Microsoft Corporation. All rights reserved.