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 

字段值

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. 你可以像访问任何其他注册表数据一样使用函数访问此数据 RegistryKeyYou 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 方法,并使用 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 方法,同时使用远程系统的计算机名称和 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 使用此键(而不是 PerformanceData 键)调用。To retrieve the data, call GetValue using this key, rather than the Registry.PerformanceData key.

备注

在 Windows Server 2003 上,用户至少必须属于性能监视器用户组才能访问此基准密钥的子项。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.

适用于