MessageQueue.GetPrivateQueuesByMachine Method

Retrieves all the private queues on the specified computer.

Namespace: System.Messaging
Assembly: System.Messaging (in system.messaging.dll)

'Declaration
Public Shared Function GetPrivateQueuesByMachine ( _
	machineName As String _
) As MessageQueue()
'Usage
Dim machineName As String
Dim returnValue As MessageQueue()

returnValue = MessageQueue.GetPrivateQueuesByMachine(machineName)
public static MessageQueue[] GetPrivateQueuesByMachine (
	String machineName
)
public static function GetPrivateQueuesByMachine (
	machineName : String
) : MessageQueue[]

Parameters

machineName

The computer from which to retrieve the private queues.

Return Value

An array of MessageQueue objects that reference the retrieved private queues.

Exception typeCondition

ArgumentException

The machineName parameter is a null reference (Nothing in Visual Basic) or an empty string ("").

MessageQueueException

An error occurred when accessing a Message Queuing method.

GetPrivateQueuesByMachine retrieves a static snapshot of the queues on a specified computer.

The following table shows whether this method is available in various Workgroup modes.

Workgroup mode

Available

Local computer

Yes

Local computer and direct format name

Yes

Remote computer

Yes

Remote computer and direct format name

Yes

The following code example retrieves lists of queues.

Imports System
Imports System.Messaging

Public Class MyNewQueue


        
        ' Provides an entry point into the application.
        '		 
        ' This example gets lists of queues by a variety
        ' of criteria.


        Public Shared Sub Main()

            ' Create a new instance of the class.
            Dim myNewQueue As New MyNewQueue()

            ' Send normal and high priority messages.
            myNewQueue.GetQueuesByCategory()
            myNewQueue.GetQueuesByLabel()
            myNewQueue.GetQueuesByComputer()
            myNewQueue.GetAllPublicQueues()
            myNewQueue.GetPublicQueuesByCriteria()
            myNewQueue.GetPrivateQueues()

            Return

        End Sub 'Main



        ' Gets a list of queues with a specified category.
        ' Sends a broadcast message to all queues in that
        ' category.
 
        Public Sub GetQueuesByCategory()

            ' Get a list of queues with the specified category.
            Dim QueueList As MessageQueue() = _
                MessageQueue.GetPublicQueuesByCategory(New _
                Guid("{00000000-0000-0000-0000-000000000001}"))

            ' Send a broadcast message to each queue in the array.
            Dim queueItem As MessageQueue
            For Each queueItem In QueueList
                queueItem.Send("Broadcast message.")
            Next queueItem

            Return

        End Sub 'GetQueuesByCategory



        ' Gets a list of queues with a specified label.
        ' Sends a broadcast message to all queues with that
        ' label.


        Public Sub GetQueuesByLabel()

            ' Get a list of queues with the specified label.
            Dim QueueList As MessageQueue() = _
                MessageQueue.GetPublicQueuesByLabel("My Label")

            ' Send a broadcast message to each queue in the array.
            Dim queueItem As MessageQueue
            For Each queueItem In QueueList
                queueItem.Send("Broadcast message.")
            Next queueItem

            Return

        End Sub 'GetQueuesByLabel



        ' Gets a list of queues on a specified computer. 
        ' Displays the list on screen.
 

        Public Sub GetQueuesByComputer()

            ' Get a list of queues on the specified computer.
            Dim QueueList As MessageQueue() = _
                MessageQueue.GetPublicQueuesByMachine("MyComputer")

            ' Display the paths of the queues in the list.
            Dim queueItem As MessageQueue
            For Each queueItem In QueueList
                Console.WriteLine(queueItem.Path)
            Next queueItem

            Return

        End Sub 'GetQueuesByComputer



        ' Gets a list of all public queues.
       

        Public Sub GetAllPublicQueues()

            ' Get a list of public queues.
            Dim QueueList As MessageQueue() = _
                MessageQueue.GetPublicQueues()

            Return

        End Sub 'GetAllPublicQueues


 
        ' Gets a list of all public queues that match 
        ' specified criteria. Displays the list on 
        ' screen.


        Public Sub GetPublicQueuesByCriteria()

            ' Define criteria to filter the queues.
            Dim myCriteria As New MessageQueueCriteria()
            myCriteria.CreatedAfter = DateTime.Now.Subtract(New _
                TimeSpan(1, 0, 0, 0))
            myCriteria.ModifiedBefore = DateTime.Now
            myCriteria.MachineName = "."
            myCriteria.Label = "My Queue"

            ' Get a list of queues with that criteria.
            Dim QueueList As MessageQueue() = _
                MessageQueue.GetPublicQueues(myCriteria)

            ' Display the paths of the queues in the list.
            Dim queueItem As MessageQueue
            For Each queueItem In QueueList
                Console.WriteLine(queueItem.Path)
            Next queueItem

            Return

        End Sub 'GetPublicQueuesByCriteria


 
        ' Gets a list of private queues on the local 
        ' computer. Displays the list on screen.
  

        Public Sub GetPrivateQueues()

            ' Get a list of queues with the specified category.
            Dim QueueList As MessageQueue() = _
                MessageQueue.GetPrivateQueuesByMachine(".")

            ' Display the paths of the queues in the list.
            Dim queueItem As MessageQueue
            For Each queueItem In QueueList
                Console.WriteLine(queueItem.Path)
            Next queueItem

            Return

        End Sub 'GetPrivateQueues

End Class 'MyNewQueue


package MyProject;

import System.*;
import System.Messaging.*;

/// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
{
    //**************************************************
    // Provides an entry point into the application.
    //         
    // This example gets lists of queues by a variety
    // of criteria.
    //**************************************************
    public static void main(String[] args)
    {
        // Create a new instance of the class.
        MyNewQueue myNewQueue = new MyNewQueue();
        // Send normal and high priority messages.
        myNewQueue.GetQueuesByCategory();
        myNewQueue.GetQueuesByLabel();
        myNewQueue.GetQueuesByComputer();
        myNewQueue.GetAllPublicQueues();
        myNewQueue.GetPublicQueuesByCriteria();
        myNewQueue.GetPrivateQueues();

        return;
    } //main

    //**************************************************
    // Gets a list of queues with a specified category.
    // Sends a broadcast message to all queues in that
    // category.
    //**************************************************
    public void GetQueuesByCategory()
    {
        // Get a list of queues with the specified category.
        MessageQueue queueList[] = MessageQueue.GetPublicQueuesByCategory(
            new Guid("{00000000-0000-0000-0000-000000000001}"));
        // Send a broadcast message to each queue in the array.
        for (int iCtr = 0; iCtr < queueList.length; iCtr++) {
            MessageQueue queueItem = queueList[iCtr];
            queueItem.Send("Broadcast message.");
        }

        return;
    } //GetQueuesByCategory

    //**************************************************
    // Gets a list of queues with a specified label.
    // Sends a broadcast message to all queues with that
    // label.
    //**************************************************
    public void GetQueuesByLabel()
    {
        // Get a list of queues with the specified label.
        MessageQueue queueList[] =
            MessageQueue.GetPublicQueuesByLabel("My Label");
        // Send a broadcast message to each queue in the array.
        for (int iCtr = 0; iCtr < queueList.length; iCtr++) {
            MessageQueue queueItem = queueList[iCtr];
            queueItem.Send("Broadcast message.");
        }

        return;
    } //GetQueuesByLabel

    //**************************************************
    // Gets a list of queues on a specified computer. 
    // Displays the list on screen.
    //**************************************************
    public void GetQueuesByComputer()
    {
        // Get a list of queues on the specified computer.
        MessageQueue queueList[] =
            MessageQueue.GetPublicQueuesByMachine("MyComputer");
        // Display the paths of the queues in the list.
        for (int iCtr = 0; iCtr < queueList.length; iCtr++) {
            MessageQueue queueItem = queueList[iCtr];
            Console.WriteLine(queueItem.get_Path());
        }

        return;
    } //GetQueuesByComputer

    //**************************************************
    // Gets a list of all public queues.
    //**************************************************
    public void GetAllPublicQueues()
    {
        // Get a list of public queues.
        MessageQueue queueList[] = MessageQueue.GetPublicQueues();

        return;
    } //GetAllPublicQueues

    //**************************************************
    // Gets a list of all public queues that match 
    // specified criteria. Displays the list on 
    // screen.
    //**************************************************
    public void GetPublicQueuesByCriteria()
    {
        // Define criteria to filter the queues.
        MessageQueueCriteria myCriteria = new MessageQueueCriteria();
        myCriteria.set_CreatedAfter(DateTime.get_Now().Subtract(
            new TimeSpan(1, 0, 0, 0)));
        myCriteria.set_ModifiedBefore(DateTime.get_Now());
        myCriteria.set_MachineName(".");
        myCriteria.set_Label("My Queue");
        // Get a list of queues with that criteria.
        MessageQueue queueList[] = MessageQueue.GetPublicQueues(myCriteria);
        // Display the paths of the queues in the list.
        for (int iCtr = 0; iCtr < queueList.length; iCtr++) {
            MessageQueue queueItem = queueList[iCtr];
            Console.WriteLine(queueItem.get_Path());
        }

        return;
    } //GetPublicQueuesByCriteria

    //**************************************************
    // Gets a list of private queues on the local 
    // computer. Displays the list on screen.
    //**************************************************
    public void GetPrivateQueues()
    {
        // Get a list of queues with the specified category.
        MessageQueue queueList[] = MessageQueue.GetPrivateQueuesByMachine(".");
        // Display the paths of the queues in the list.
        for (int iCtr = 0; iCtr < queueList.length; iCtr++) {
            MessageQueue queueItem = queueList[iCtr];
            Console.WriteLine(queueItem.get_Path());
        }

        return;
    } //GetPrivateQueues
} //MyNewQueue

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show: