Performance counter installation on Vista

| 5 Comments
I've been aware that there was a 'need to run as Administrator' issue with some of my server examples for a while; only the ones that installed/removed performance counter dlls or installed/removed themselves as Windows Services. The service installation problem was obvious, you got a message box saying that the user had insufficient rights and now, on Vista, this message box lets you try again and it relaunches the application with the "run_as" verb and you get a chance to run it as Admin... The performance counter issue seems more complex. Firstly the counters I use are based on some code from Programming Server Side Applications by Jeffrey Richter and I lamented on how code reuse can bite you way back in 2000... I still haven't got around to rewriting the code to my house style so it still uses assertions and it still doesn't report errors in a way that I'd like... Anyway... Today I've spent a while trying to work out why, on my 64 bit Vista box, I can't write to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009\Counters even as an Administrator... I still haven't found the reason, I get a 'bad key' error both in the code and when I try and use RegEdt32 on it... It works fine on a 64 bit XP virtual machine so I don't think it's anything to do with the 64 bit registry tricks... Ho hum... My list of boring things to try next includes building an VS2005 ATL performance counter object and trying to install that (their code seems to be based on the same Richter original but the string registration bit (the bit that's broken for me) works differently...), installing a clean VM Vista and seeing if it works in that and building the latest Platform SDK perfmon sample and using LoadCtrs to install it and seeing what it does and where...

5 Comments

Thanks, I decided to re-write the perfmon code so that it did things "properly" and now everything works fine ;)

Hi

I have run into the exact same problem. I based my performance counter stuff on Jeffrey Richter's MSDN code, which worked fine on XP, but won't on Windows 7.

You mentioned you re-wrote your perfmon code to cope. Can you offer any advice on that or, better still, any code? Because I'm going to have to do the same thing, and I'm not looking forward to it.

Thanks for any help.
--
Sean

Sean,

You can license the perfmon code from me if you want to, it's usually sold as part of my server framework, but I expect I can break it out so that you don't need to take a full framework license. I'll drop you an email.

If you don't fancy licensing the code then all I can say is that I started from scratch with regards to the perfmon code rewrite and it was quite a lot of work. I ended up with a schema class so that the schema could be built programatically at runtime rather than declaratively with macros as is done with Richter's code but I expect a declarative style would work as well. The schema can then be interrogated to generate the required files for registering the counters using the API. I think you could probably replace the Richter style direct registry poking installation code with something that generates the required files from Richter's macro'd counters but I wanted a full rewrite to improve error handling and bring the code in line with my house style.

Sean,

You might want to follow up on that link that Mat posted for a work around. It seems the easiest method of getting your existing counters installed.

Leave a comment