ネットワーク上のすべてのパブリック キューを列挙するための前方向カーソル セマンティクスをサポートします。
Overloads Public Shared Function GetMessageQueueEnumerator() As _
MessageQueueEnumerator
[C#]
public static MessageQueueEnumerator GetMessageQueueEnumerator();
[C++]
public: static MessageQueueEnumerator* GetMessageQueueEnumerator();
[JScript]
public static function GetMessageQueueEnumerator() :
MessageQueueEnumerator;
戻り値
ネットワーク上のすべてのパブリックメッセージ キューの動的リストを作成する MessageQueueEnumerator 。
解説
GetMessageQueueEnumerator のこのオーバーロードは、ネットワーク上のすべてのパブリック キューの列挙体を返します。
カーソルは動的リストに関連付けられるため、現在のカーソル位置よりも後ろでキューが削除または追加された場合、列挙体はキューに対して行った変更を反映します。カーソルの現在位置よりも前でキューが追加または削除された場合、変更は反映されません。たとえば、カーソル位置よりも後ろに追加されたキューに、列挙子は自動的にアクセスできます。しかし、その位置よりも前に挿入されたキューにはアクセスできません。ただし、列挙体はリセットできます。つまり、 MessageQueueEnumerator に対して Reset を呼び出して、リストの先頭にカーソルを戻すことができます。
メモ ネットワークでのキューの順序は定義されていません。列挙子は、コンピュータ、ラベル、パブリック ステータス、プライベート ステータスなどアクセス可能な基準によってキューを順序付けることはありません。
ネットワーク上のキューへの動的接続ではなく、静的スナップショットが必要な場合は、 GetPublicQueues または GetPrivateQueuesByMachine を呼び出します。2 つのメソッドはそれぞれ、メソッドが呼び出された時点でのキューを表す MessageQueue オブジェクトの配列を返します。
このメソッドが各種のワークグループ モードで使用できるかどうかを次の表に示します。
| ワークグループ モード | 使用可否 |
|---|---|
| ローカル コンピュータ | いいえ |
| ローカル コンピュータ + 直接書式名 | いいえ |
| リモート コンピュータ | いいえ |
| リモート コンピュータ + 直接書式名 | いいえ |
使用例
[Visual Basic, C#, C++] ネットワーク上のすべてのメッセージ キューを反復処理し、各キューのパスを取得する例を次に示します。この例では最後に、ネットワーク上のパブリック キューの数を表示します。
Imports System
Imports 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 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
End Namespace 'MyProject
[C#]
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;
}
}
}
[C++]
#using <mscorlib.dll>
#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(S"Number of public queues: {0}", __box(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();
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン
をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
.NET Framework セキュリティ:
- 直前の呼び出し元の完全信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細の参照先 : 部分信頼コードからのライブラリの使用
参照
MessageQueue クラス | MessageQueue メンバ | System.Messaging 名前空間 | MessageQueue.GetMessageQueueEnumerator オーバーロードの一覧 | GetPrivateQueuesByMachine | GetPublicQueues | GetPublicQueuesByCategory | GetPublicQueuesByLabel | GetPublicQueuesByMachine | GetMessageEnumerator