MessageQueue.GetMessageQueueEnumerator メソッド

定義

列挙子オブジェクトを作成し、ネットワーク上のパブリック キューの動的リストを作成します。

オーバーロード

GetMessageQueueEnumerator()

ネットワーク上のすべてのパブリック キューを列挙するための順方向専用カーソル セマンティクスをサポートします。

GetMessageQueueEnumerator(MessageQueueCriteria)

指定した基準を満たすネットワーク上のすべてのパブリック キューを列挙するための順方向専用カーソル セマンティクスをサポートします。

GetMessageQueueEnumerator()

ネットワーク上のすべてのパブリック キューを列挙するための順方向専用カーソル セマンティクスをサポートします。

public:
 static System::Messaging::MessageQueueEnumerator ^ GetMessageQueueEnumerator();
public static System.Messaging.MessageQueueEnumerator GetMessageQueueEnumerator ();
static member GetMessageQueueEnumerator : unit -> System.Messaging.MessageQueueEnumerator
Public Shared Function GetMessageQueueEnumerator () As MessageQueueEnumerator

戻り値

ネットワーク上のすべてのパブリックメッセージ キューの動的リストを作成する MessageQueueEnumerator

次のコード例では、ネットワーク内のすべてのメッセージ キューを反復処理し、各キューのパスを調べます。 最後に、ネットワーク上のパブリック キューの数が表示されます。

#using <System.dll>
#using <System.Messaging.dll>

using namespace System;
using namespace System::Messaging;

//**************************************************
// Iterates through message queues and examines the
// path for each queue. Also displays the number of
// public queues on the network.
//**************************************************
void ListPublicQueues()
{
   
   // Holds the count of private queues.
   int numberQueues = 0;
   
   // Get a cursor into the queues on the network.
   MessageQueueEnumerator^ myQueueEnumerator = MessageQueue::GetMessageQueueEnumerator();
   
   // Move to the next queue and read its path.
   while ( myQueueEnumerator->MoveNext() )
   {
      
      // Increase the count if priority is Lowest.
      Console::WriteLine( myQueueEnumerator->Current->Path );
      numberQueues++;
   }

   
   // Display final count.
   Console::WriteLine( "Number of public queues: {0}", numberQueues );
   return;
}


//**************************************************
// Provides an entry point into the application.
//   
// This example uses a cursor to step through the
// message queues and list the public queues on the
// network.
//**************************************************
int main()
{
   
   // Output the count of Lowest priority messages.
   ListPublicQueues();
}
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 uses a cursor to step through the
        // message queues and list the public queues on the
        // network.
        //**************************************************

        public static void Main()
        {
            // Create a new instance of the class.
            MyNewQueue myNewQueue = new MyNewQueue();

            // Output the count of Lowest priority messages.
            myNewQueue.ListPublicQueues();
                        
            return;
        }

        //**************************************************
        // Iterates through message queues and examines the
        // path for each queue. Also displays the number of
        // public queues on the network.
        //**************************************************
        
        public void ListPublicQueues()
        {
            // Holds the count of private queues.
            uint numberQueues = 0;
    
            // Get a cursor into the queues on the network.
            MessageQueueEnumerator myQueueEnumerator =
                MessageQueue.GetMessageQueueEnumerator();

            // Move to the next queue and read its path.
            while(myQueueEnumerator.MoveNext())
            {
                // Increase the count if priority is Lowest.
                Console.WriteLine(myQueueEnumerator.Current.Path);
                numberQueues++;
            }

            // Display final count.
            Console.WriteLine("Number of public queues: " +
                numberQueues.ToString());
            
            return;
        }
    }
}
Imports System.Messaging



Public Class MyNewQueue


        
        ' Provides an entry point into the application.
        '		 
        ' This example uses a cursor to step through the
        ' message queues and list the public queues on the
        ' network.
        

        Public Shared Sub Main()

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

            ' Output the count of Lowest priority messages.
            myNewQueue.ListPublicQueues()

            Return

        End Sub


        
        ' Iterates through message queues and examines the
        ' path for each queue. Also displays the number of
        ' public queues on the network.
        

        Public Sub ListPublicQueues()

            ' Holds the count of private queues.
            Dim numberQueues As Int32 = 0

            ' Get a cursor into the queues on the network.
            Dim myQueueEnumerator As MessageQueueEnumerator = _
                MessageQueue.GetMessageQueueEnumerator()

            ' Move to the next queue and read its path.
            While myQueueEnumerator.MoveNext()
                ' Increase the count if the priority is Lowest.
                Console.WriteLine(myQueueEnumerator.Current.Path)
                numberQueues += 1
            End While

            ' Display final count.
            Console.WriteLine(("Number of public queues: " + _
                numberQueues.ToString()))

            Return

        End Sub

End Class

注釈

この オーバーロードは GetMessageQueueEnumerator 、ネットワーク上にあるすべてのパブリック キューの列挙を返します。

カーソルは動的リストに関連付けられているため、列挙には、カーソルの現在位置を超えて削除または追加されたキューのキュー リストに対して行った変更が反映されます。 カーソルの現在位置の前にあるキューの追加または削除は反映されません。 たとえば、列挙子は、カーソル位置の後に追加されたキューに自動的にアクセスできますが、その位置の前に挿入されたキューにはアクセスできません。 ただし、 を呼び出ResetMessageQueueEnumeratorすことで列挙体をリセットし、カーソルをリストの先頭に戻すことができます。

ネットワーク内のキューの順序は定義されていません。 列挙子は、コンピューター、ラベル、パブリックまたはプライベートの状態、その他のアクセス可能な条件など、それらを順序付けしません。

ネットワーク上のキューへの動的接続ではなく、そのキューの静的スナップショットが必要な場合は、 または を呼び出しますGetPublicQueuesGetPrivateQueuesByMachine(String)。 これら 2 つの各メソッドは、 メソッドが MessageQueue 呼び出された時点のキューを表す オブジェクトの配列を返します。

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

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

こちらもご覧ください

適用対象

GetMessageQueueEnumerator(MessageQueueCriteria)

指定した基準を満たすネットワーク上のすべてのパブリック キューを列挙するための順方向専用カーソル セマンティクスをサポートします。

public:
 static System::Messaging::MessageQueueEnumerator ^ GetMessageQueueEnumerator(System::Messaging::MessageQueueCriteria ^ criteria);
public static System.Messaging.MessageQueueEnumerator GetMessageQueueEnumerator (System.Messaging.MessageQueueCriteria criteria);
static member GetMessageQueueEnumerator : System.Messaging.MessageQueueCriteria -> System.Messaging.MessageQueueEnumerator
Public Shared Function GetMessageQueueEnumerator (criteria As MessageQueueCriteria) As MessageQueueEnumerator

パラメーター

criteria
MessageQueueCriteria

利用できるメッセージ キューのフィルター処理に使用する基準が格納されている MessageQueueCriteria

戻り値

criteria パラメーターで指定された制約を満たすネットワーク上のパブリックメッセージ キューの動的リストを作成する MessageQueueEnumerator

次のコード例では、メッセージ キューを反復処理し、最後の日に作成され、コンピューター "MyComputer" に存在する各キューのパスを表示します。

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

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

   // Iterates through message queues and displays the
   // path of each queue that was created in the last
   // day and that exists on the computer "MyComputer". 
   void ListPublicQueuesByCriteria()
   {
      UInt32 numberQueues = 0;
      
      // Specify the criteria to filter by.
      MessageQueueCriteria^ myCriteria = gcnew MessageQueueCriteria;
      myCriteria->MachineName = "MyComputer";
      myCriteria->CreatedAfter = DateTime::Now.Subtract( TimeSpan(1,0,0,0) );
      
      // Get a cursor into the queues on the network.
      MessageQueueEnumerator^ myQueueEnumerator = MessageQueue::GetMessageQueueEnumerator( myCriteria );
      
      // Move to the next queue and read its path.
      while ( myQueueEnumerator->MoveNext() )
      {
         
         // Increase the count if priority is Lowest.
         Console::WriteLine( myQueueEnumerator->Current->Path );
         numberQueues++;
      }

      
      // Handle no queues matching the criteria.
      if ( numberQueues == 0 )
      {
         Console::WriteLine( "No public queues match criteria." );
      }

      return;
   }

};

int main()
{
   
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;
   
   // Output the count of Lowest priority messages.
   myNewQueue->ListPublicQueuesByCriteria();
   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 uses a cursor to step through the
        // message queues and list the public queues on the
        // network that specify certain criteria.
        //**************************************************

        public static void Main()
        {
            // Create a new instance of the class.
            MyNewQueue myNewQueue = new MyNewQueue();

            // Output the count of Lowest priority messages.
            myNewQueue.ListPublicQueuesByCriteria();
                        
            return;
        }

        //**************************************************
        // Iterates through message queues and displays the
        // path of each queue that was created in the last
        // day and that exists on the computer "MyComputer".
        //**************************************************
        
        public void ListPublicQueuesByCriteria()
        {
            uint numberQueues = 0;
            
            // Specify the criteria to filter by.
            MessageQueueCriteria myCriteria = new
                MessageQueueCriteria();
            myCriteria.MachineName = "MyComputer";
            myCriteria.CreatedAfter = DateTime.Now.Subtract(new
                TimeSpan(1,0,0,0));

            // Get a cursor into the queues on the network.
            MessageQueueEnumerator myQueueEnumerator =
                MessageQueue.GetMessageQueueEnumerator(myCriteria);

            // Move to the next queue and read its path.
            while(myQueueEnumerator.MoveNext())
            {
                // Increase the count if priority is Lowest.
                Console.WriteLine(myQueueEnumerator.Current.Path);
                numberQueues++;
            }

            // Handle no queues matching the criteria.
            if (numberQueues == 0)
            {
                Console.WriteLine("No public queues match criteria.");
            }

            return;
        }
    }
}
Imports System.Messaging

 
Public Class MyNewQueue


        '
        ' Provides an entry point into the application.
        '		 
        ' This example uses a cursor to step through the
        ' message queues and list the public queues on the
        ' network that specify certain criteria.
        

        Public Shared Sub Main()

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

            ' Output the count of Lowest priority messages.
            myNewQueue.ListPublicQueuesByCriteria()

            Return

        End Sub


        
        ' Iterates through message queues and displays the
        ' path of each queue that was created in the last
        ' day and that exists on the computer "MyComputer". 
        

        Public Sub ListPublicQueuesByCriteria()

            Dim numberQueues As Int32 = 0

            ' Specify the criteria to filter by.
            Dim myCriteria As New MessageQueueCriteria()
            myCriteria.MachineName = "MyComputer"
            myCriteria.CreatedAfter = DateTime.Now.Subtract(New _
                TimeSpan(1, 0, 0, 0))


            ' Get a cursor into the queues on the network.
            Dim myQueueEnumerator As MessageQueueEnumerator = _
                MessageQueue.GetMessageQueueEnumerator(myCriteria)

            ' Move to the next queue and read its path.
            While myQueueEnumerator.MoveNext()
                ' Increase the count if the priority is Lowest.
                Console.WriteLine(myQueueEnumerator.Current.Path)
                numberQueues += 1
            End While

            ' Handle no queues matching the criteria.
            If numberQueues = 0 Then
                Console.WriteLine("No queues match the criteria.")
            End If

            Return

        End Sub

End Class

注釈

のこのオーバーロード GetMessageQueueEnumerator は、アプリケーション条件で定義されている条件を満たすネットワーク上のすべてのパブリック キューの一覧を返します。 キューの作成または変更時刻、コンピューター名、ラベル、カテゴリ、またはこれらの任意の組み合わせなど、含める条件を指定できます。

カーソルは動的リストに関連付けられているため、列挙には、カーソルの現在位置を超えて発生するキューに加えた変更が反映されます。 カーソルの現在位置の前にあるキューへの変更は反映されません。 たとえば、列挙子は、カーソル位置の後に追加されたキューに自動的にアクセスできますが、その位置の前に挿入されたキューにはアクセスできません。 ただし、 を呼び出ResetMessageQueueEnumeratorすことで列挙体をリセットし、カーソルをリストの先頭に戻すことができます。

ネットワーク内のキューの順序は定義されていません。 列挙子は、コンピューター、ラベル、パブリックまたはプライベートの状態、その他のアクセス可能な条件など、それらを順序付けしません。

ネットワーク上のキューへの動的接続ではなく、静的スナップショットを作成する場合は、 の条件を指定するか、 を GetPublicQueues 呼び出します GetPrivateQueuesByMachine(String)。 これら 2 つの各メソッドは、 メソッドが MessageQueue 呼び出された時点のキューを表す オブジェクトの配列を返します。 、、または GetPublicQueuesByMachine(String) を呼び出すとGetPublicQueuesByCategory(Guid)、それぞれ、、および MachineNameLabelCategoryフィルター条件を使用して を呼び出すとGetPublicQueues同じ結果が得られます。 GetPublicQueuesByLabel(String)

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

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

こちらもご覧ください

適用対象