Okay, So I'm basically trying to create a list of installed Performance Counter Categories, like the one you get in PerfMon. For this I'm using

System.Diagnostics.PerformanceCounterCategory.GetCategories()

which seems like it works, until you inspect the list, and find out that some are missing. The first one I spotted missing was the ReadyBoost Cache. This was because the project was set to compile on "x86". Changing this to "Any CPU" fixed that issue.

However there are still some that are missing, for instance, one of the test machines has a "Authorization Manager Applications" Category (mine doesn't, and nobody seems to know why, or where it comes from) However, on that machine, that Performance Counter Category shows up in PerfMon, but not when invoking the GetCategories() method from C#.

Does anyone know why? Is there a more reliable way to get PerformanceCounterCategories? Is this because I'm using .Net? Is there some native API I can use instead?

EDIT

I'm sorry, I still don't get it. I've written this code to perhaps better illustrate it:

using System;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.Win32;

namespace PccHack
{
    class Program
    {
        private static readonly Regex Numeric = new Regex(@"^\d+$");
        static void Main(string[] args)
        {
            var pcc1 = PerformanceCounterCategory.GetCategories();
            Console.Out.WriteLine("Getting automatically from the microsoft framework gave {0} results.", pcc1.Count());
            string[] counters;
            using (var regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009"))
            {
                counters = regKey.GetValue("Counter") as string[];
            }
            var pcc2 = counters.Where(counter => !Numeric.IsMatch(counter)).ToList
Edit
Report