大网数据广告活动
性能与资源

Creating a Performance Extension DLL

· 52CE 我爱测

A provider is a performance DLL that provides counter data to consumers.

Important: Due to significant performance and reliability limitations, the method for providing performance counter data that this topic describes may be altered or unavailable in the future. Instead, Microsoft recommends that you use the method described in Providing Counter Data Using Version 2.0 for creating new performance counters and that you migrate existing performance counters to use that method as well.

A V1 provider uses a performance DLL that provides counter data to consumers. The performance DLL must export the OpenPerformanceData, CollectPerformanceData, and ClosePerformanceData functions. Typically, you use a module definition (.def) file to export the functions from the DLL. The system calls these functions when a consumer queries performance data.

The first time a consumer calls RegQueryValueEx, or if the consumer uses the RegOpenKey or RegConnectRegistry function to open HKEY_PERFORMANCE_DATA, the system calls the OpenPerformanceData function for each provider that is registered on the computer. The exception is if the provider specifies the list of objects that it supports in the [objects] section of the .INI file. In this case, the system calls the provider only if one of the queried objects matches an object from the list.

The OpenPerformanceData function gives each provider an opportunity to initialize its performance data structures. Then, if the OpenPerformanceData function returns successfully, the system calls the provider's CollectPerformanceData function. Subsequent calls to RegQueryValueEx cause the system to call the CollectPerformanceData function.

When the consumer finishes collecting performance data, it specifies HKEY_PERFORMANCE_DATA in a call to the RegCloseKey function. This causes the system to call the ClosePerformanceData function for each provider. The providers are then unloaded.

It is possible for multiple consumers to collect performance data at the same time. The system calls OpenPerformanceData and ClosePerformanceData functions only once each time the DLL is loaded or unloaded.

Note: Be sure to include extern "C" in your C++ code to prevent the compiler from adding decorations to your function names; otherwise, the system may fail to find your functions.

Note: If an error occurs while loading your performance DLL, finding your functions, or calling your functions, the system will disable the provider for subsequent collections within the same process. In addition, if this occurs while running in a privileged process, the system adds a Disable Performance Counters value to your Performance key to prevent the provider from being loaded in the future.

For more information on writing a performance DLL, see the following topics:

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 07/14/2025
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。