tags:

views:

47

answers:

4

I need to get basic information about the computer's processor in a WPF application I'm writing.

Data such as "Intel(R) core(TM) 2 Quad CPU Q6600 @ 2.4GHz"

How do I do this?

A: 

Some of what you're looking for is exposed by properties of the System.Environment class. You might also be interested in the System.Windows.Forms.SystemInformation class.

Jim Mischel
+1  A: 

Use WMI

using System.Management;

private static string GetProcessorID()
    {

      ManagementClass mgt = new ManagementClass("Win32_Processor");
      ManagementObjectCollection procs= mgt.GetInstances();
        foreach ( ManagementObject item in procs)
             return item.Properties["Name"].Value.ToString();

        return "Unknown";
    }
Paul Creasey
A: 

This information (and much, much more) is available via Windows Management Instrumentation (or WMI for short). It isn't technically tied to WPF. Please take a look at this article to get you started!

hmemcpy
A: 

Use WMI to obtain the information needed, especially the classes in the System.Management namespace. First. add a reference to the System.Management assembly, then use code similar to this one:

ManagementClass wmiManagementProcessorClass = new ManagementClass("Win32_Processor");
ManagementObjectCollection wmiProcessorCollection = wmiManagementProcessorClass.GetInstances();
foreach (ManagementObject wmiProcessorObject in wmiProcessorCollection)
{
    try
    {
        MessageBox.Show(wmiProcessorObject.Properties["Name"].Value.ToString());
    }
    catch (ManagementException ex)
    {
        // real error handling here
        MessageBox.Show(ex.Message);
    }
}
Jim Brissom