InstanceDataCollectionCollection.Keys プロパティ

定義

オブジェクトと、インスタンス データ コレクションに関連付けられているオブジェクトのカウンター レジストリ キーを取得します。

public:
 property System::Collections::ICollection ^ Keys { System::Collections::ICollection ^ get(); };
public System.Collections.ICollection Keys { get; }
member this.Keys : System.Collections.ICollection
Public ReadOnly Property Keys As ICollection

プロパティ値

オブジェクト固有のレジストリ キーのセットを表す ICollection

次のコード例では、 の InstanceDataCollectionCollection プロパティをKeys使用してカウンター名のコレクションを返し、 を のString配列に変換します。 プロパティを使用して オブジェクトの InstanceDataCollection 配列を Values 生成します。 カウンター名の配列内の各要素に対して、名前が表示され、関数が呼び出されて、関連付けられた InstanceDataCollectionを処理します。


// Process the InstanceDataCollectionCollection for this category.
PerformanceCounterCategory pcc = new PerformanceCounterCategory(categoryName);
InstanceDataCollectionCollection idColCol = pcc.ReadCategory();

ICollection idColColKeys = idColCol.Keys;
string[] idCCKeysArray = new string[idColColKeys.Count];
idColColKeys.CopyTo(idCCKeysArray, 0);

ICollection idColColValues = idColCol.Values;
InstanceDataCollection[] idCCValuesArray = new InstanceDataCollection[idColColValues.Count];
idColColValues.CopyTo(idCCValuesArray, 0);

Console.WriteLine("InstanceDataCollectionCollection for \"{0}\" " +
    "has {1} elements.", categoryName, idColCol.Count);

// Display the InstanceDataCollectionCollection Keys and Values.
// The Keys and Values collections have the same number of elements.
int index;
for(index=0; index<idCCKeysArray.Length; index++)
{
    Console.WriteLine("  Next InstanceDataCollectionCollection " +
        "Key is \"{0}\"", idCCKeysArray[index]);
    ProcessInstanceDataCollection(idCCValuesArray[index]);
}

' Process the InstanceDataCollectionCollection for this category.
Dim pcc As New PerformanceCounterCategory(categoryName)
Dim idColCol As InstanceDataCollectionCollection = pcc.ReadCategory()

Dim idColColKeys As ICollection = idColCol.Keys
Dim idCCKeysArray(idColColKeys.Count - 1) As String
idColColKeys.CopyTo(idCCKeysArray, 0)

Dim idColColValues As ICollection = idColCol.Values
Dim idCCValuesArray(idColColValues.Count - 1) As InstanceDataCollection
idColColValues.CopyTo(idCCValuesArray, 0)

Console.WriteLine("InstanceDataCollectionCollection for ""{0}"" " & _
    "has {1} elements.", categoryName, idColCol.Count)

' Display the InstanceDataCollectionCollection Keys and Values.
' The Keys and Values collections have the same number of elements.
Dim index As Integer
For index = 0 To idCCKeysArray.Length - 1
    Console.WriteLine("  Next InstanceDataCollectionCollection " & _
        "Key is ""{0}""", idCCKeysArray(index))
    ProcessInstanceDataCollection(idCCValuesArray(index))
Next index

注釈

各ソフトウェア コンポーネントは、インストール時にオブジェクトとカウンターのキーを作成し、実行中にカウンター データを書き込みます。 他のレジストリ データにアクセスする場合と同様に、このデータにアクセスできます。 ただし、パフォーマンス データの収集にはレジストリを使用しますが、データはレジストリ データベースに格納されません。 代わりに、システムは適切なシステム・オブジェクト・マネージャーからデータを収集します。

適用対象