InstanceDataCollection.Keys 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取对象和与该实例数据关联的对象的计数器注册表项。
public:
 property System::Collections::ICollection ^ Keys { System::Collections::ICollection ^ get(); };public System.Collections.ICollection Keys { get; }member this.Keys : System.Collections.ICollectionPublic ReadOnly Property Keys As ICollection属性值
表示一组对象特定的注册表项的 ICollection。
示例
下面的代码示例使用 Keys 的 InstanceDataCollection 属性返回实例名称的集合,该集合将其转换为 数组 String。 它使用 Values 属性生成对象的数组InstanceData。 对于实例名称数组中的每个元素,它显示名称并调用函数来处理关联的 InstanceData 对象。
// Display the contents of an InstanceDataCollection.
public static void ProcessInstanceDataCollection(InstanceDataCollection idCol)
{
    ICollection idColKeys = idCol.Keys;
    string[] idColKeysArray = new string[idColKeys.Count];
    idColKeys.CopyTo(idColKeysArray, 0);
    ICollection idColValues = idCol.Values;
    InstanceData[] idColValuesArray = new InstanceData[idColValues.Count];
    idColValues.CopyTo(idColValuesArray, 0);
    Console.WriteLine("  InstanceDataCollection for \"{0}\" " +
        "has {1} elements.", idCol.CounterName, idCol.Count);
    // Display the InstanceDataCollection Keys and Values.
    // The Keys and Values collections have the same number of elements.
    int index;
    for(index=0; index<idColKeysArray.Length; index++)
    {
        Console.WriteLine("    Next InstanceDataCollection " +
            "Key is \"{0}\"", idColKeysArray[index]);
        ProcessInstanceDataObject(idColValuesArray[index]);
    }
}
' Display the contents of an InstanceDataCollection.
Sub ProcessInstanceDataCollection(ByVal idCol As InstanceDataCollection)
    Dim idColKeys As ICollection = idCol.Keys
    Dim idColKeysArray(idColKeys.Count - 1) As String
    idColKeys.CopyTo(idColKeysArray, 0)
    Dim idColValues As ICollection = idCol.Values
    Dim idColValuesArray(idColValues.Count - 1) As InstanceData
    idColValues.CopyTo(idColValuesArray, 0)
    Console.WriteLine("  InstanceDataCollection for ""{0}"" " & _
        "has {1} elements.", idCol.CounterName, idCol.Count)
    ' Display the InstanceDataCollection Keys and Values.
    ' The Keys and Values collections have the same number of elements.
    Dim index As Integer
    For index = 0 To idColKeysArray.Length - 1
        Console.WriteLine("    Next InstanceDataCollection " & _
            "Key is ""{0}""", idColKeysArray(index))
        ProcessInstanceDataObject(idColValuesArray(index))
    Next index
End Sub
注解
每个软件组件在安装时为其对象和计数器创建密钥,并在执行时写入计数器数据。 可以像访问任何其他注册表数据一样访问此数据。 但是,尽管使用注册表来收集性能数据,但数据不会存储在注册表数据库中。 相反,系统从相应的系统对象管理器收集数据。