Bagikan melalui


Registry.PerformanceData Bidang

Definisi

Berisi informasi performa untuk komponen perangkat lunak. Bidang ini membaca kunci dasar registri 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 

Nilai Bidang

Contoh

Contoh berikut menunjukkan cara mengambil subkey kunci ini, dan mencetak namanya ke layar. OpenSubKey Gunakan metode untuk membuat instans subkunci tertentu yang diminati. Anda kemudian dapat menggunakan operasi RegistryKey lain untuk memanipulasi kunci tersebut. Perhatikan bahwa contoh ini sering tidak dapat mengembalikan hasil, karena mungkin tidak ada data performa.

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

Keterangan

Setiap komponen perangkat lunak membuat kunci untuk objeknya, penghitung ketika diinstal, dan menulis data penghitung saat dijalankan. Anda dapat mengakses data ini karena Anda akan mengakses data registri lainnya, menggunakan RegistryKey fungsi .

Meskipun Anda menggunakan registri untuk mengumpulkan data performa, data tidak disimpan dalam database registri. Sebaliknya, mengakses registri dengan kunci ini menyebabkan sistem mengumpulkan data dari manajer objek sistem yang sesuai.

Untuk mendapatkan data performa dari sistem lokal, gunakan GetValue metode , dengan kunci Registry.PerformanceData. Panggilan pertama membuka kunci (Anda tidak perlu secara eksplisit membuka kunci terlebih dahulu). Namun, pastikan untuk menggunakan Close metode untuk menutup handel ke kunci ketika Anda selesai mendapatkan data performa. Pengguna tidak dapat menginstal atau menghapus komponen perangkat lunak saat data performanya sedang digunakan.

Untuk mendapatkan data performa dari sistem jarak jauh, Anda harus menggunakan OpenRemoteBaseKey metode , dengan nama komputer sistem jarak jauh dan kunci Registry.PerformanceData. Panggilan ini mengambil kunci yang mewakili data performa untuk sistem jarak jauh. Untuk mengambil data, panggil GetValue menggunakan kunci ini, bukan kunci Registry.PerformanceData.

Catatan

Pada Windows Server 2003, pengguna setidaknya harus termasuk dalam grup Pengguna Monitor Performa untuk mengakses subkunci kunci dasar ini.

Berlaku untuk