DLL Interaction with a Performance Monitor Application

An application retrieves performance data by specifying HKEY_PERFORMANCE_DATA in a call to the RegQueryValueEx function. If successful, the RegQueryValueEx function fills a buffer of the application with the requested performance data.

The first time an application calls the RegQueryValueEx function, or if the application uses the RegOpenKey function to open HKEY_PERFORMANCE_DATA, the system calls the Open function for each application with matching registry entries. This behavior gives each performance DLL an opportunity to initialize its performance data structures. If the Open function returns successfully, or if there is no Open function, the system calls the Collect function. Subsequent calls to the RegQueryValueEx function cause the system to call the Collect function.

When the application has finished collecting performance data, it specifies HKEY_PERFORMANCE_DATA in a call to the RegCloseKey function. This causes the system to call the Close function for each application. The performance DLLs then unload.

It is possible for multiple programs to collect performance data at the same time. The system calls the Open and Close functions only once for each application requesting performance data. For remote measurement, the system limits access to these routines to one thread at a time, so synchronization is not a problem. However, for local measurement, because multiple processes may be making simultaneous calls, you must prevent any conflicts from multiple concurrent requests for data.

When calling functions from within a performance DLL, remember that ExitProcess, ExitThread, CreateThread, CreateRemoteThread, and a process that starts as the result of a call by CreateProcess are serialized within a process. In an address space, only one of these events can happen at any one time, and the following restrictions apply:

  • During process startup and DLL initialization routines, new threads can be created, but they do not begin execution until DLL initialization is finished for the process.
  • Only one thread at a time can be in a DLL initialization or detach routine.
  • The ExitProcess function does not return until no threads are in their DLL initialization or detach routines.

 Last updated on Friday, October 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.