How can I get the processor NAME of my machine using C#(.NET 3.5)?
Asked Answered
T

2

7

I need to find the Name and speed of the processor on my machine. I'm building an open source help desk suite and finding this really entertaining!

Thanks for the help guys!

Tennilletennis answered 25/4, 2010 at 15:4 Comment(0)
S
13

As the others have pointed out, using WMI. Do this by adding a reference to System.Management.dll, then calling the following code:

ManagementObjectSearcher mos = 
  new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor");
    foreach (ManagementObject mo in mos.Get()) {
      Console.WriteLine(mo["Name"]);
    }

Besides "Name", WMI also exposes other interesting facts about your processor. Take a look at http://msdn.microsoft.com/en-us/library/aa394373(VS.85).aspx for the definitive list.

Saxe answered 25/4, 2010 at 15:16 Comment(2)
I can only find the System.Management.Instrumentation DLL in the Add Reference menu.Tennilletennis
Even if the assembly's on your system and in your GAC, it won't show up in Visual Studio's dialog box unless there's an entry for it in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFoldersSaxe
S
7

If using Windows Registry is possible then query for: HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0\ProcessorNameString

If multiple physical/logical processors are present then values other than zero might be used

Sculpturesque answered 9/5, 2020 at 19:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.