Opens a queue for receiving messages. If the queue does not exist and the protocol is set to OS, the method tries to create a queue and fails if this is not possible.


[In] Name

The name of the queue in one of the following:

  • MachineName\QueueName (OS or PathName)

  • IPAddress\QueueName (TCP)

  • SPXAddress\QueueName (SPX)

[In] Protocol

Refers to the network protocol you must use when you connect to the queue. The options are:

  • 0: OS (default value) - any machine name supported by the underlying operating system. For Microsoft Windows NT4, it is either UNC or DNS.

  • 1: TCP (TCP/IP) - Internet address notation (IP address).

  • 2: SPX - network number and host number (separated by the ":" character).

[In] Mode

Reflects the mode in which the queue will be opened. The mode options are:

  • 0: DIRECT (default value) - see the MSDN Platform SDK (Opening Queues with a Direct Format Name) for further information.

  • 1: PRIVATE

  • 2: PUBLIC

When the protocol contains a value that has no meaning, the default OS protocol is used. When you set Mode to DIRECT, a FormatName (see below) is used. Any other Mode uses a PathName.


You use direct format names to reference public or private queues without accessing the directory. You can use direct format names when performing the following operations:

The general format of direct format names is shown below. Note that you can directly access public, private and (for MSMQ 2.0 clients and servers) computer system queues.

FormatName Syntax Examples

AddressSpecification\QueueName (for public queues)

AddressSpecification\PRIVATE\QueueName (for private queues)

AddressSpecification\SYSTEM$,computersystemqueue (introduced in MSMQ 2.0 for computer journal and dead-letter queues)\myQueue (Mode Direct, Protocol TCP)\myQueue (Mode Direct, Protocol OS)

00000012:00a0234f7500\myQueue (Mode Direct, Protocol SPX, supported only on Windows NT4 and Windows 2000)

More information:

IMSMQBusAdapter Interface