Registry.PerformanceData 字段

定义

包含软件组件的性能信息。Contains performance information for software components. 该字段读取 Windows 注册表基项 HKEY_PERFORMANCE_DATA。This field reads the Windows registry base key 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 

字段值

示例

下面的示例演示如何检索此项的子项,并将其名称在屏幕上的打印。The following example demonstrates how to retrieve the subkeys of this key, and prints their names to the screen. 使用OpenSubKey方法来创建感兴趣的特定子项的一个实例。Use the OpenSubKey method to create an instance of the particular subkey of interest. 然后,可以使用中的其他操作RegistryKey来操作该注册表项。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.

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

注解

每个软件组件创建其对象计数器时它在安装,并在执行时将计数器数据写入的项。Each software component creates keys for its objects, counters when it is installed, and writes counter data while it is executing. 可以访问此数据,如可访问任何其他注册表数据,使用RegistryKey函数。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.

若要从本地系统获取性能数据,请使用GetValue方法,与 Registry.PerformanceData 键。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). 但是,务必使用Close方法关闭该密钥的句柄完成后获取性能数据。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.

若要从远程系统获取性能数据,必须使用OpenRemoteBaseKey方法,与远程系统和 Registry.PerformanceData 密钥的计算机名称。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. 若要检索的数据,调用GetValue使用此密钥,而不是 Registry.PerformanceData 密钥。To retrieve the data, call GetValue using this key, rather than the Registry.PerformanceData key.

备注

在 Windows Server 2003 中,用户必须至少属于 Performance Monitor Users 组才能访问此基项的子项。On Windows Server 2003, a user must at least belong to the Performance Monitor Users group in order to access subkeys of this base key.

适用于