Registry.PerformanceData Поле

Определение

Содержит сведения о производительности для компонентов программного обеспечения. Это поле считывает базовый раздел реестра Windows HKEY_PERFORMANCE_DATA.

public: static initonly Microsoft::Win32::RegistryKey ^ PerformanceData;
public static readonly Microsoft.Win32.RegistryKey PerformanceData;
 staticval mutable PerformanceData : Microsoft.Win32.RegistryKey
Public Shared ReadOnly PerformanceData As RegistryKey 

Значение поля

Примеры

В следующем примере показано, как получить подразделы этого ключа и вывести их имена на экран. Используйте метод для OpenSubKey создания экземпляра конкретного подраздела, который интересует. Затем можно использовать другие операции в для RegistryKey управления этим ключом. Обратите внимание, что этот пример часто может не возвращать никаких результатов, так как данные о производительности могут быть отсутствуют.

using namespace System;
using namespace Microsoft::Win32;
void PrintKeys( RegistryKey ^ rkey )
{
   
   // Retrieve all the subkeys for the specified key.
   array<String^>^names = rkey->GetSubKeyNames();
   int icount = 0;
   Console::WriteLine( "Subkeys of {0}", rkey->Name );
   Console::WriteLine( "-----------------------------------------------" );
   
   // Print the contents of the array to the console.
   System::Collections::IEnumerator^ enum0 = names->GetEnumerator();
   while ( enum0->MoveNext() )
   {
      String^ s = safe_cast<String^>(enum0->Current);
      Console::WriteLine( s );
      
      // The following code puts a limit on the number
      // of keys displayed.  Comment it out to print the
      // complete list.
      icount++;
      if ( icount >= 10 )
            break;
   }
}

int main()
{
   
   // Create a RegistryKey, which will access the HKEY_PERFORMANCE_DATA
   // key in the registry of this machine.
   RegistryKey ^ rk = Registry::PerformanceData;
   
   // Print out the keys.
   PrintKeys( rk );
}
using System;
using Microsoft.Win32;

class Reg {
    public static void Main() {

        // Create a RegistryKey, which will access the HKEY_PERFORMANCE_DATA
        // key in the registry of this machine.
        RegistryKey rk = Registry.PerformanceData;

        // Print out the keys.
        PrintKeys(rk);
    }

    static void PrintKeys(RegistryKey rkey) {

        // Retrieve all the subkeys for the specified key.
        string [] names = rkey.GetSubKeyNames();

        int icount = 0;

        Console.WriteLine("Subkeys of " + rkey.Name);
        Console.WriteLine("-----------------------------------------------");

        // Print the contents of the array to the console.
        foreach (string s in names) {
            Console.WriteLine(s);

            // The following code puts a limit on the number
            // of keys displayed.  Comment it out to print the
            // complete list.
            icount++;
            if (icount >= 10)
                break;
        }
    }
}
Imports Microsoft.Win32

Class Reg
    
    Public Shared Sub Main()
        
        ' Create a RegistryKey, which will access the HKEY_PERFORMANCE_DATA 
        ' key in the registry of this machine.
        Dim rk As RegistryKey = Registry.PerformanceData
        
        ' Print out the keys.
        PrintKeys(rk)
    End Sub    
    
    Shared Sub PrintKeys(rkey As RegistryKey)
        
        ' Retrieve all the subkeys for the specified key.
        Dim names As String() = rkey.GetSubKeyNames()
        
        Dim icount As Integer = 0
        
        Console.WriteLine("Subkeys of " & rkey.Name)
        Console.WriteLine("-----------------------------------------------")
        
        ' Print the contents of the array to the console.
        Dim s As String
        For Each s In  names
            Console.WriteLine(s)
            
            ' The following code puts a limit on the number
            ' of keys displayed.  Comment it out to print the
            ' complete list.
            icount += 1            
            If icount >= 10 Then
                Exit For
            End If
        Next s
    End Sub
End Class

Комментарии

Каждый программный компонент создает ключи для своих объектов, счетчиков при установке и записывает данные счетчиков во время выполнения. Вы можете получить доступ к этим данным так же, как и к любым другим данным реестра с помощью RegistryKey функций .

Хотя вы используете реестр для сбора данных о производительности, эти данные не хранятся в базе данных реестра. Вместо этого доступ к реестру с помощью этого раздела приводит к тому, что система будет собирать данные из соответствующих диспетчеров системных объектов.

Чтобы получить данные о производительности из локальной системы, используйте GetValue метод с разделом Registry.PerformanceData. При первом вызове ключ открывается (не нужно открывать ключ явным образом). Однако обязательно используйте Close метод , чтобы закрыть дескриптор ключа после завершения получения данных о производительности. Пользователь не может установить или удалить программный компонент, пока используются данные о производительности.

Чтобы получить данные о производительности из удаленной системы, необходимо использовать OpenRemoteBaseKey метод с именем удаленной системы и ключом Registry.PerformanceData. Этот вызов извлекает ключ, представляющий данные о производительности для удаленной системы. Чтобы получить данные, вызовите GetValue , используя этот раздел, а не раздел Registry.PerformanceData.

Примечание

В Windows Server 2003 пользователь должен по крайней мере принадлежать к группе пользователей Монитор производительности, чтобы получить доступ к подразделам этого базового ключа.

Применяется к