Creating a Performance Extension DLL
A provider is 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. 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 for each consumer requesting performance data.
For more information on writing a performance DLL, see the following topics:
- Implementing the OpenPerformanceData function
- Implementing the CollectPerformanceData function
- Error Handling in the DLL
- Restricting Access to Performance Extension DLLs
- Performance DLL Samples