Retrieves all the private queues on the specified computer.
[Visual Basic] Public Shared Function GetPrivateQueuesByMachine( _ ByVal machineName As String _ ) As MessageQueue () [C#] public static MessageQueue[] GetPrivateQueuesByMachine( string machineName ); [C++] public: static MessageQueue* GetPrivateQueuesByMachine( String* machineName ) []; [JScript] public static function GetPrivateQueuesByMachine( machineName : String ) : MessageQueue[];
An array of type MessageQueue that references the private queues retrieved.
Exception Type | Condition |
---|---|
ArgumentException | The machineName parameter is a null reference (in Visual Basic Nothing) or an empty string (""). |
MessageQueueException | The attempt to access the queue's machine name generated an exception specified by the given status message. |
GetPrivateQueuesByMachine retrieves a static snapshot of the queues on the specified computer. You cannot retrieve the private queues on a remote computer, because private queues are not published across the entire network.
Private queue paths include text identifying them as private queues. Use MachineName\Private$\ QueueName to specify the Path for a private queue. For example myComputer\Private$\myQueue.
GetPrivateQueuesByMachine is a static (in Visual Basic Shared) method, so it can be called on the MessageQueue class itself. It is not necessary to instantiate a MessageQueue to call the method.
The following example retrieves a list of private queues on a computer. Then, it calls Peek on the first message in each queue.
[Visual Basic]
Private Sub GetPrivateQueueList() 'Define an array to hold the private queues. Dim mqList() As MessageQueue 'Define a message object. Dim msg As Message 'This is used in the for loop. Dim i As Integer 'Get the private queues on the computer. mqList = MessageQueue.GetPrivateQueuesByMachine("myComputer") For i = 0 To mqList.Length - 1 'Peek the top message in each private queue. msg = mqList(i).Peek Next End Sub
MessageQueue Class | MessageQueue Members | System.Messaging Namespace | MachineName | GetPublicQueuesByMachine