Registry.PerformanceData Campo

Definizione

Contiene informazioni sulle prestazioni per i componenti software. Questo campo legge la chiave di base del Registro di sistema 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 

Valore del campo

Esempio

Nell'esempio seguente viene illustrato come recuperare le sottochiavi di questa chiave e stamparne i nomi sullo schermo. Utilizzare il OpenSubKey metodo per creare un'istanza della sottochiave specifica di interesse. È quindi possibile usare altre operazioni in RegistryKey per modificare tale chiave. Si noti che questo esempio spesso non restituisce risultati, perché potrebbero non esserci dati sulle prestazioni.

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

Commenti

Ogni componente software crea chiavi per i relativi oggetti, contatori quando viene installato e scrive i dati del contatore durante l'esecuzione. È possibile accedere a questi dati come si accede a qualsiasi altro dato del Registro di sistema, usando le RegistryKey funzioni .

Anche se si usa il Registro di sistema per raccogliere dati sulle prestazioni, i dati non vengono archiviati nel database del Registro di sistema. L'accesso al Registro di sistema con questa chiave fa invece in modo che il sistema raccolga i dati dai gestori oggetti di sistema appropriati.

Per ottenere dati sulle prestazioni dal sistema locale, usare il GetValue metodo , con la chiave Registry.PerformanceData. La prima chiamata apre la chiave (non è necessario aprire prima la chiave in modo esplicito). Tuttavia, assicurarsi di usare il Close metodo per chiudere l'handle alla chiave al termine dell'acquisizione dei dati sulle prestazioni. L'utente non può installare o rimuovere un componente software mentre i dati sulle prestazioni sono in uso.

Per ottenere dati sulle prestazioni da un sistema remoto, è necessario usare il OpenRemoteBaseKey metodo , con il nome del computer del sistema remoto e la chiave Registry.PerformanceData. Questa chiamata recupera una chiave che rappresenta i dati sulle prestazioni per il sistema remoto. Per recuperare i dati, chiamare GetValue usando questa chiave anziché la chiave Registry.PerformanceData.

Note

In Windows Server 2003, un utente deve almeno appartenere al gruppo utenti Monitor prestazioni per accedere alle sottochiavi di questa chiave di base.

Si applica a