MessageQueue.GetMessageQueueEnumerator MessageQueue.GetMessageQueueEnumerator MessageQueue.GetMessageQueueEnumerator MessageQueue.GetMessageQueueEnumerator Method

定義

為網路上公用佇列的動態清單建立列舉值物件。Creates an enumerator object for a dynamic listing of the public queues on the network.

多載

GetMessageQueueEnumerator() GetMessageQueueEnumerator() GetMessageQueueEnumerator() GetMessageQueueEnumerator()

提供順向資料指標語意,以列舉網路上的所有公用佇列。Provides forward-only cursor semantics to enumerate through all public queues on the network.

GetMessageQueueEnumerator(MessageQueueCriteria) GetMessageQueueEnumerator(MessageQueueCriteria) GetMessageQueueEnumerator(MessageQueueCriteria) GetMessageQueueEnumerator(MessageQueueCriteria)

提供順向資料指標語意,以列舉網路上所有符合指定準則的公用佇列。Provides forward-only cursor semantics to enumerate through all public queues on the network that meet the specified criteria.

GetMessageQueueEnumerator() GetMessageQueueEnumerator() GetMessageQueueEnumerator() GetMessageQueueEnumerator()

提供順向資料指標語意,以列舉網路上的所有公用佇列。Provides forward-only cursor semantics to enumerate through all public queues on the network.

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

傳回

提供網路上所有公用訊息佇列動態清單的 MessageQueueEnumeratorA MessageQueueEnumerator that provides a dynamic listing of all the public message queues on the network.

範例

下列程式碼範例會逐一查看網路中的所有訊息佇列, 並檢查每個佇列的路徑。The following code example iterates through all the message queues in the network, and examines the path for each queue. 最後, 它會顯示網路上的公用佇列數目。Finally, it displays the number of public queues on the network.

#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
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 'Main


        
        ' 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 'ListPublicQueues

End Class 'MyNewQueue

備註

GetMessageQueueEnumerator這個多載會傳回網路上所有公用佇列的列舉。This overload of GetMessageQueueEnumerator returns an enumeration of all the public queues that are on the network.

因為資料指標與動態清單相關聯, 所以列舉會反映您對佇列清單所做的任何修改, 以刪除或加入至資料指標目前位置以外的佇列。Because the cursor is associated with a dynamic listing, the enumeration reflects any modification you make to a queue list for queues deleted or added beyond the cursor's current position. 新增或刪除位於資料指標目前位置之前的佇列, 則不會反映出來。Additions or deletion of queues located before the cursor's current position are not reflected. 例如, 列舉值可以自動存取超出游標位置的附加佇列, 而不是插入到該位置之前的一個。For example, the enumerator can automatically access a queue appended beyond the cursor position but not one inserted before that position. 不過, 您可以重設列舉, 藉由呼叫Reset MessageQueueEnumerator來將游標移回清單的開頭。However, you can reset the enumeration, thereby moving the cursor back to the beginning of the list, by calling Reset for the MessageQueueEnumerator.

網路中沒有已定義的佇列排序。There is no defined ordering of queues in a network. 列舉值不會依電腦、標籤、公用或私用狀態或任何其他可存取的準則排序。An enumerator does not order them, for example, by computer, label, public or private status, or any other accessible criteria.

如果您想要在網路上使用佇列的靜態快照集, 而不是動態連接, 請GetPublicQueues呼叫GetPrivateQueuesByMachine(String)或。If you want a static snapshot of the queues on the network rather than a dynamic connection to them, call GetPublicQueues or GetPrivateQueuesByMachine(String). 這兩個方法中的每一個都會MessageQueue傳回物件的陣列, 代表呼叫方法時的佇列。Each of these two methods returns an array of MessageQueue objects, which represent the queues at the time the method was called.

下表顯示這個方法是否可在各種工作組模式中使用。The following table shows whether this method is available in various Workgroup modes.

工作組模式Workgroup mode 可用Available
本機電腦Local computer No
本機電腦和直接格式名稱Local computer and direct format name No
遠端電腦Remote computer No
遠端電腦和直接格式名稱Remote computer and direct format name No
另請參閱

GetMessageQueueEnumerator(MessageQueueCriteria) GetMessageQueueEnumerator(MessageQueueCriteria) GetMessageQueueEnumerator(MessageQueueCriteria) GetMessageQueueEnumerator(MessageQueueCriteria)

提供順向資料指標語意,以列舉網路上所有符合指定準則的公用佇列。Provides forward-only cursor semantics to enumerate through all public queues on the network that meet the specified criteria.

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 MessageQueueCriteria MessageQueueCriteria

MessageQueueCriteria,包含用來篩選可用訊息佇列的準則。A MessageQueueCriteria that contains the criteria used to filter the available message queues.

傳回

提供網路上所有公用訊息佇列動態清單的 MessageQueueEnumerator,其符合 criteria 參數指定的限制。A MessageQueueEnumerator that provides a dynamic listing of the public message queues on the network that satisfy the restrictions specified by the criteria parameter.

範例

下列程式碼範例會逐一查看訊息佇列, 並顯示過去一天內所建立且存在於電腦 "MyComputer" 上的每個佇列的路徑。The following code example 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".

#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
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 'Main


        
        ' 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 'ListPublicQueuesByCriteria

End Class 'MyNewQueue

備註

GetMessageQueueEnumerator這個多載會傳回網路上, 符合應用程式準則中所定義準則的所有公用佇列清單。This overload of GetMessageQueueEnumerator returns a listing of all the public queues on the network that satisfy criteria defined in the application criteria. 您可以指定要包含的準則, 例如, 佇列建立或修改時間、電腦名稱稱、標籤、類別, 或這些的任何組合。You can specify the criteria to include, for example, queue creation or modification time, computer name, label, category, or any combination of these.

因為資料指標與動態清單相關聯, 所以列舉會反映出您對佇列所做的任何修改, 而這會在資料指標目前的位置之外發生。Because the cursor is associated with a dynamic listing, the enumeration reflects any modification you make to a queue that occurs beyond the cursor's current position. 在資料指標目前位置之前的佇列變更不會反映出來。Changes to queues located before the cursor's current position are not reflected. 例如, 列舉值可以自動存取超出游標位置的附加佇列, 而不是插入到該位置之前的一個。For example, the enumerator can automatically access a queue appended beyond the cursor position but not one inserted before that position. 不過, 您可以重設列舉, 藉由呼叫Reset MessageQueueEnumerator來將游標移回清單的開頭。However, you can reset the enumeration, thereby moving the cursor back to the beginning of the list, by calling Reset for the MessageQueueEnumerator.

網路中沒有已定義的佇列排序。There is no defined ordering of queues in a network. 列舉值不會依電腦、標籤、公用或私用狀態或任何其他可存取的準則排序。An enumerator does not order them, for example, by computer, label, public or private status, or any other accessible criteria.

如果您想要在網路上使用佇列的靜態快照集, 而不是動態連接, 請指定GetPublicQueues或呼叫GetPrivateQueuesByMachine(String)的準則。If you want a static snapshot of the queues on the network rather than a dynamic connection to them, specify criteria for GetPublicQueues or call GetPrivateQueuesByMachine(String). 這兩個方法中的每一個都會MessageQueue傳回物件的陣列, 代表呼叫方法時的佇列。Each of these two methods returns an array of MessageQueue objects, which represent the queues at the time the method was called. 呼叫GetPublicQueuesByCategory(Guid)GetPublicQueues Category或, 會提供與使用、Label和的MachineName篩選準則呼叫相同的結果。 GetPublicQueuesByLabel(String) GetPublicQueuesByMachine(String)Calling GetPublicQueuesByCategory(Guid), GetPublicQueuesByLabel(String), or GetPublicQueuesByMachine(String) provides the same results as calling GetPublicQueues with the filtering criteria of Category, Label, and MachineName, respectively.

下表顯示這個方法是否可在各種工作組模式中使用。The following table shows whether this method is available in various Workgroup modes.

工作組模式Workgroup mode 可用Available
本機電腦Local computer No
本機電腦和直接格式名稱Local computer and direct format name No
遠端電腦Remote computer No
遠端電腦和直接格式名稱Remote computer and direct format name No
另請參閱

適用於