0

So I have a program, where i'm getting general information about the user's machine. And I'm attempting to get multiple entries from WMI's Win32_Processor, namely the processors name, clockspeed, architecture and core count. However, selecting the whole thing is very speed detrimental. So i'm trying to figure out if I can query for multiple entries without using a wildcard.

            ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_Processor");
        searcher.Get();

        foreach (ManagementObject share in searcher.Get())
        {
            var clockSpeedM = share["CurrentClockSpeed"];
            var Name = share["Name"];
            var CoreCount = share["NumberOfCores"];

            double clockSpeedG = Math.Round(Convert.ToDouble(clockSpeedM) / 1000, 2);

            if (share["Architecture"].ToString() == "9")
            {
                Name = Name + " (64-bit)";
            }
            else
            {
                Name = Name + " (32-bit)";
            }

            return Name + " " + CoreCount + " cores" + " ~" + clockSpeedG + "GHz";

        }
  • 1
    Just replace that `*` with the names of the columns you want. Column names should be separated by a comma. Also note that `ManagementObjectSearcher` implements `IDisposable`, so you should dispose it after use. The easiest way to do that is to wrap it in a `using` statement. – Pieter Witvoet May 08 '17 at 15:20
  • Thanks for the help! – SomeStupidKid May 08 '17 at 18:01

0 Answers0