Skip to main content
added 677 characters in body
Source Link
Dale Wilson
  • 9.5k
  • 3
  • 37
  • 52

The support for adding C++ performance counters changed in Vista and beyond. The Performance DLL approach suggested in another answer still works, but the new technique described here is easier to use.

In this approach you write a manifest that describes your counters, run CTRPP, a tool that generates code from your manifest. Compile and link this code with your application, and add a call to initialize the process (it starts a background thread), and add code to update the counters as necessary. The details of publishing the counters are handled by the background thread running the generated code.

You also need to run lodctr /m:[manifest file] to register your counters before they can be used. This must be run as an admin.

BTW: Another program, unlodctr reverse the effect of lodctr and must be used if you make any changes to your counters because there is no "replace" operation, only delete the old, then install the new.

<RANT>Documentation for all the above is just plain awful. For example lodctr was completely reworked for Vista, but the doc in MSDN is all for the XP version and no longer applies. If you visit MSDN please use the "This documentation is not helpful" button liberally and maybe Microsoft will get the message.</RANT>

The support for adding C++ performance counters changed in Vista and beyond. The Performance DLL approach suggested in another answer still works, but the new technique described here is easier to use.

In this approach you write a manifest that describes your counters, run a tool that generates code from your manifest. Compile and link this code with your application, and add a call to initialize the process (it starts a background thread), and add code to update the counters as necessary. The details of publishing the counters are handled by the background thread running the generated code.

The support for adding C++ performance counters changed in Vista and beyond. The Performance DLL approach suggested in another answer still works, but the new technique described here is easier to use.

In this approach you write a manifest that describes your counters, run CTRPP, a tool that generates code from your manifest. Compile and link this code with your application, and add a call to initialize the process (it starts a background thread), and add code to update the counters as necessary. The details of publishing the counters are handled by the background thread running the generated code.

You also need to run lodctr /m:[manifest file] to register your counters before they can be used. This must be run as an admin.

BTW: Another program, unlodctr reverse the effect of lodctr and must be used if you make any changes to your counters because there is no "replace" operation, only delete the old, then install the new.

<RANT>Documentation for all the above is just plain awful. For example lodctr was completely reworked for Vista, but the doc in MSDN is all for the XP version and no longer applies. If you visit MSDN please use the "This documentation is not helpful" button liberally and maybe Microsoft will get the message.</RANT>

Source Link
Dale Wilson
  • 9.5k
  • 3
  • 37
  • 52

The support for adding C++ performance counters changed in Vista and beyond. The Performance DLL approach suggested in another answer still works, but the new technique described here is easier to use.

In this approach you write a manifest that describes your counters, run a tool that generates code from your manifest. Compile and link this code with your application, and add a call to initialize the process (it starts a background thread), and add code to update the counters as necessary. The details of publishing the counters are handled by the background thread running the generated code.