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) で制限する場合は、このメソッドの別のオーバーロードを使用します。 (または、、、または GetPublicQueuesByLabel(String)を使用GetPublicQueuesByCategory(Guid)GetPublicQueuesByMachine(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)) が含まれます。 このオーバーロードを使用して、これらの条件の 1 つ以上を満たすネットワーク上のすべてのパブリック キューの一覧を取得します (たとえば、ラベルとカテゴリの両方を指定する場合)。 、、および MachineName以外LabelCategoryのメッセージ条件でフィルター処理することもできます。 たとえば、このオーバーロードを使用して、キューの最終変更時刻でフィルター処理します。 クラスの MessageQueueCriteria 新しいインスタンスを作成し、インスタンスに適切なプロパティを設定し、インスタンスを パラメーターとして criteria 渡すだけです。

GetPublicQueues は、キューの静的スナップショットを取得します。 キューの動的リストを操作するには、 を使用 GetMessageQueueEnumeratorします。

次の表は、このメソッドがさまざまなワークグループ モードで使用できるかどうかを示しています。

ワークグループ モード 利用可能
ローカル コンピューター いいえ
ローカル コンピューターと直接の形式名 いいえ
リモート コンピューター いいえ
リモート コンピューターと直接形式の名前 いいえ

こちらもご覧ください

適用対象