MessageQueue.GetPublicQueues 方法

定义

检索网络上的所有公共队列。

重载

GetPublicQueues()

检索网络上的所有公共队列。

GetPublicQueues(MessageQueueCriteria)

检索网络上满足指定判据的所有公共队列。

GetPublicQueues()

检索网络上的所有公共队列。

public:
 static cli::array <System::Messaging::MessageQueue ^> ^ GetPublicQueues();
public static System.Messaging.MessageQueue[] GetPublicQueues ();
static member GetPublicQueues : unit -> System.Messaging.MessageQueue[]
Public Shared Function GetPublicQueues () As MessageQueue()

返回

引用检索的公共队列的 MessageQueue 对象数组。

例外

访问“消息队列”方法时出错。

示例

下面的代码示例检索队列列表。

#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;
using namespace System::Collections;
ref class MyNewQueue
{
public:

   // Gets a list of queues with a specified category.
   // Sends a broadcast message to all queues in that
   // category.
   void GetQueuesByCategory()
   {
      
      // Get a list of queues with the specified category.
      array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueuesByCategory( Guid(" {00000000-0000-0000-0000-000000000001}") );
      
      // Send a broadcast message to each queue in the array.
      IEnumerator^ myEnum = QueueList->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
         queueItem->Send( "Broadcast message." );
      }

      return;
   }


   // Gets a list of queues with a specified label.
   // Sends a broadcast message to all queues with that
   // label.
   void GetQueuesByLabel()
   {
      
      // Get a list of queues with the specified label.
      array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueuesByLabel( "My Label" );
      
      // Send a broadcast message to each queue in the array.
      IEnumerator^ myEnum = QueueList->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
         queueItem->Send( "Broadcast message." );
      }

      return;
   }


   // Gets a list of queues on a specified computer. 
   // Displays the list on screen.
   void GetQueuesByComputer()
   {
      
      // Get a list of queues on the specified computer.
      array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueuesByMachine( "MyComputer" );
      
      // Display the paths of the queues in the list.
      IEnumerator^ myEnum = QueueList->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
         Console::WriteLine( queueItem->Path );
      }

      return;
   }


   // Gets a list of all public queues.
   void GetAllPublicQueues()
   {
      
      // Get a list of public queues.
      array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueues();
      return;
   }


   // Gets a list of all public queues that match 
   // specified criteria. Displays the list on 
   // screen.
   void GetPublicQueuesByCriteria()
   {
      
      // Define criteria to filter the queues.
      MessageQueueCriteria^ myCriteria = gcnew MessageQueueCriteria;
      myCriteria->CreatedAfter = DateTime::Now.Subtract( TimeSpan(1,0,0,0) );
      myCriteria->ModifiedBefore = DateTime::Now;
      myCriteria->MachineName = ".";
      myCriteria->Label = "My Queue";
      
      // Get a list of queues with that criteria.
      array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueues( myCriteria );
      
      // Display the paths of the queues in the list.
      IEnumerator^ myEnum = QueueList->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
         Console::WriteLine( queueItem->Path );
      }

      return;
   }


   // Gets a list of private queues on the local 
   // computer. Displays the list on screen.
   void GetPrivateQueues()
   {
      
      // Get a list of queues with the specified category.
      array<MessageQueue^>^QueueList = MessageQueue::GetPrivateQueuesByMachine( "." );
      
      // Display the paths of the queues in the list.
      IEnumerator^ myEnum = QueueList->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
         Console::WriteLine( queueItem->Path );
      }

      return;
   }

};


// Provides an entry point into the application.
// This example gets lists of queues by a variety
// of criteria.
int main()
{
   
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;
   
   // Send normal and high priority messages.
   myNewQueue->GetQueuesByCategory();
   myNewQueue->GetQueuesByLabel();
   myNewQueue->GetQueuesByComputer();
   myNewQueue->GetAllPublicQueues();
   myNewQueue->GetPublicQueuesByCriteria();
   myNewQueue->GetPrivateQueues();
   return 0;
}
using System;
using System.Messaging;

namespace MyProject
{
    /// <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()
        {
            // 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;
        }

        //**************************************************
        // 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.
            foreach(MessageQueue queueItem in QueueList)
            {
                queueItem.Send("Broadcast message.");
            }
            
            return;
        }

        //**************************************************
        // 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.
            foreach(MessageQueue queueItem in QueueList)
            {
                queueItem.Send("Broadcast message.");
            }
            
            return;
        }

        //**************************************************
        // 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.
            foreach(MessageQueue queueItem in QueueList)
            {
                Console.WriteLine(queueItem.Path);
            }

            return;
        }

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

        //**************************************************
        // 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.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.
            MessageQueue[] QueueList =
                MessageQueue.GetPublicQueues(myCriteria);

            // Display the paths of the queues in the list.
            foreach(MessageQueue queueItem in QueueList)
            {
                Console.WriteLine(queueItem.Path);
            }

            return;
        }

        //**************************************************
        // 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.
            foreach(MessageQueue queueItem in QueueList)
            {
                Console.WriteLine(queueItem.Path);
            }
            
            return;
        }
    }
}
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



        ' 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



        ' 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



        ' 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



        ' 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


 
        ' 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


 
        ' 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

End Class

注解

如果需要网络上所有公共队列的完整列表,请使用此重载。 如果要按特定条件(如 MachineNameCategory或上次修改时间)限制列表,请使用此方法的另一个重载。 (或者,可以使用 GetPublicQueuesByMachine(String)GetPublicQueuesByCategory(Guid)GetPublicQueuesByLabel(String).)

GetPublicQueues 检索队列的静态快照。 若要与队列的动态列表交互,请使用 GetMessageQueueEnumerator

下表显示了此方法在各种工作组模式下是否可用。

工作组模式 可用
本地计算机
本地计算机和直接格式名称
远程计算机
远程计算机和直接格式名称

另请参阅

适用于

GetPublicQueues(MessageQueueCriteria)

检索网络上满足指定判据的所有公共队列。

public:
 static cli::array <System::Messaging::MessageQueue ^> ^ GetPublicQueues(System::Messaging::MessageQueueCriteria ^ criteria);
public static System.Messaging.MessageQueue[] GetPublicQueues (System.Messaging.MessageQueueCriteria criteria);
static member GetPublicQueues : System.Messaging.MessageQueueCriteria -> System.Messaging.MessageQueue[]
Public Shared Function GetPublicQueues (criteria As MessageQueueCriteria) As MessageQueue()

参数

criteria
MessageQueueCriteria

MessageQueueCriteria,包含用于筛选队列的判据。

返回

引用检索的公共队列的 MessageQueue 对象数组。

例外

访问“消息队列”方法时出错。

示例

下面的代码示例检索队列列表。

#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;
using namespace System::Collections;
ref class MyNewQueue
{
public:

   // Gets a list of queues with a specified category.
   // Sends a broadcast message to all queues in that
   // category.
   void GetQueuesByCategory()
   {
      
      // Get a list of queues with the specified category.
      array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueuesByCategory( Guid(" {00000000-0000-0000-0000-000000000001}") );
      
      // Send a broadcast message to each queue in the array.
      IEnumerator^ myEnum = QueueList->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
         queueItem->Send( "Broadcast message." );
      }

      return;
   }


   // Gets a list of queues with a specified label.
   // Sends a broadcast message to all queues with that
   // label.
   void GetQueuesByLabel()
   {
      
      // Get a list of queues with the specified label.
      array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueuesByLabel( "My Label" );
      
      // Send a broadcast message to each queue in the array.
      IEnumerator^ myEnum = QueueList->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
         queueItem->Send( "Broadcast message." );
      }

      return;
   }


   // Gets a list of queues on a specified computer. 
   // Displays the list on screen.
   void GetQueuesByComputer()
   {
      
      // Get a list of queues on the specified computer.
      array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueuesByMachine( "MyComputer" );
      
      // Display the paths of the queues in the list.
      IEnumerator^ myEnum = QueueList->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
         Console::WriteLine( queueItem->Path );
      }

      return;
   }


   // Gets a list of all public queues.
   void GetAllPublicQueues()
   {
      
      // Get a list of public queues.
      array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueues();
      return;
   }


   // Gets a list of all public queues that match 
   // specified criteria. Displays the list on 
   // screen.
   void GetPublicQueuesByCriteria()
   {
      
      // Define criteria to filter the queues.
      MessageQueueCriteria^ myCriteria = gcnew MessageQueueCriteria;
      myCriteria->CreatedAfter = DateTime::Now.Subtract( TimeSpan(1,0,0,0) );
      myCriteria->ModifiedBefore = DateTime::Now;
      myCriteria->MachineName = ".";
      myCriteria->Label = "My Queue";
      
      // Get a list of queues with that criteria.
      array<MessageQueue^>^QueueList = MessageQueue::GetPublicQueues( myCriteria );
      
      // Display the paths of the queues in the list.
      IEnumerator^ myEnum = QueueList->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
         Console::WriteLine( queueItem->Path );
      }

      return;
   }


   // Gets a list of private queues on the local 
   // computer. Displays the list on screen.
   void GetPrivateQueues()
   {
      
      // Get a list of queues with the specified category.
      array<MessageQueue^>^QueueList = MessageQueue::GetPrivateQueuesByMachine( "." );
      
      // Display the paths of the queues in the list.
      IEnumerator^ myEnum = QueueList->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         MessageQueue^ queueItem = safe_cast<MessageQueue^>(myEnum->Current);
         Console::WriteLine( queueItem->Path );
      }

      return;
   }

};


// Provides an entry point into the application.
// This example gets lists of queues by a variety
// of criteria.
int main()
{
   
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;
   
   // Send normal and high priority messages.
   myNewQueue->GetQueuesByCategory();
   myNewQueue->GetQueuesByLabel();
   myNewQueue->GetQueuesByComputer();
   myNewQueue->GetAllPublicQueues();
   myNewQueue->GetPublicQueuesByCriteria();
   myNewQueue->GetPrivateQueues();
   return 0;
}
using System;
using System.Messaging;

namespace MyProject
{
    /// <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()
        {
            // 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;
        }

        //**************************************************
        // 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.
            foreach(MessageQueue queueItem in QueueList)
            {
                queueItem.Send("Broadcast message.");
            }
            
            return;
        }

        //**************************************************
        // 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.
            foreach(MessageQueue queueItem in QueueList)
            {
                queueItem.Send("Broadcast message.");
            }
            
            return;
        }

        //**************************************************
        // 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.
            foreach(MessageQueue queueItem in QueueList)
            {
                Console.WriteLine(queueItem.Path);
            }

            return;
        }

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

        //**************************************************
        // 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.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.
            MessageQueue[] QueueList =
                MessageQueue.GetPublicQueues(myCriteria);

            // Display the paths of the queues in the list.
            foreach(MessageQueue queueItem in QueueList)
            {
                Console.WriteLine(queueItem.Path);
            }

            return;
        }

        //**************************************************
        // 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.
            foreach(MessageQueue queueItem in QueueList)
            {
                Console.WriteLine(queueItem.Path);
            }
            
            return;
        }
    }
}
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



        ' 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



        ' 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



        ' 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



        ' 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


 
        ' 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


 
        ' 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

End Class

注解

如果要按标签、类别或计算机名称筛选网络上的所有公共队列,则 MessageQueue 类包含提供该功能的特定方法分别 (GetPublicQueuesByLabel(String)GetPublicQueuesByCategory(Guid)GetPublicQueuesByMachine(String)) 。 使用此重载可获取网络上满足多个条件的所有公共队列的列表 (例如,如果要同时指定标签和类别) 。 还可以按 、 和 MachineName以外的LabelCategory消息条件进行筛选。 例如,使用此重载按队列的上次修改时间进行筛选。 只需创建 类的新实例 MessageQueueCriteria ,在 实例中设置适当的属性,然后将实例作为 criteria 参数传递。

GetPublicQueues 检索队列的静态快照。 若要与队列的动态列表交互,请使用 GetMessageQueueEnumerator

下表显示了此方法在各种工作组模式下是否可用。

工作组模式 可用
本地计算机
本地计算机和直接格式名称
远程计算机
远程计算机和直接格式名称

另请参阅

适用于