Export (0) Print
Expand All

Registry.PerformanceData Field

Contains performance information for software components. This field reads the Windows registry base key HKEY_PERFORMANCE_DATA.

[Visual Basic]
Public Shared ReadOnly PerformanceData As RegistryKey
[C#]
public static readonly RegistryKey PerformanceData;
[C++]
public: static RegistryKey* PerformanceData;
[JScript]
public static var PerformanceData : RegistryKey;

Remarks

Each software component creates keys for its objects, counters when it is installed, and writes counter data while it is executing. You can access this data as you would access any other registry data, using the RegistryKey functions.

Although you use the registry to collect performance data, the data is not stored in the registry database. Instead, accessing the registry with this key causes the system to collect the data from the appropriate system object managers.

To obtain performance data from the local system, use the GetValue method, with the Registry.PerformanceData key. The first call opens the key (you do not need to explicitly open the key first). However, be sure to use the Close method to close the handle to the key when you are finished obtaining performance data. The user cannot install or remove a software component while its performance data is in use.

To obtain performance data from a remote system, you must use the OpenRemoteBaseKey method, with the computer name of the remote system and the Registry.PerformanceData key. This call retrieves a key representing the performance data for the remote system. To retrieve the data, call GetValue using this key, rather than the Registry.PerformanceData key.

Example

[Visual Basic, C#, C++] The following example demonstrates how to retrieve the subkeys of this key, and prints their names to the screen. Use the OpenSubKey method to create an instance of the particular subkey of interest. You can then use other operations in RegistryKey to manipulate that key. Note that this example can often return no results, since there might be no performance data.

[Visual Basic] 
Imports System
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

[C#] 
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;
        }
    }
}

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace Microsoft::Win32;

void PrintKeys(RegistryKey* rkey) {

    // Retrieve all the subkeys for the specified key.
    String* names[] = rkey->GetSubKeyNames();

    int icount = 0;

    Console::WriteLine(S"Subkeys of {0}", rkey->Name);
    Console::WriteLine(S"-----------------------------------------------");

    // Print the contents of the array to the console.
    System::Collections::IEnumerator* enum0 = names->GetEnumerator();
    while (enum0->MoveNext())
    {
        String* s = __try_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);
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Registry Class | Registry Members | Microsoft.Win32 Namespace

Show:
© 2015 Microsoft