Does anybody know of a method for creating custom Performance Counters using ordinary unmanaged Visual C++?
I know that it can be done easily using managed C++, but I need to do it using an unmanaged Windows service.
I also know that you can retrieve performance counter data, but I need to create some custom counters and increment them during the applications runtime.
views:
1488answers:
3See here: http://msdn.microsoft.com/en-us/library/aa371925.aspx
It is not really hard, but a bit tedious as the API involves extensive usage of self-referential, variable-length structures and has to employ some IPC mechanism to obtain the data from the monitored process.
I was looking for something a litte easier to implement. I will probably have to use this approach. I was also shown by a colleague (thanks PJ) that there is a Scribble tutorial that has been modified to show how to add a Performance Counter using ATL classes: PerformanceScribble Sample: Performance Monitoring in an MFC Application
The big drawback here is that currently my application doesn't use MFC or ATL, and I would have to add the support for it.
Don't use the ATL performance monitor classes. I know they are easy to add and they have a wizard and all, but they are hopelessly bugged. I added them to one of my development apps at work, then had to go through and rip the code out 6 months later. All in all about 3 weeks work lost to that noise.