• Use WMI to get Processor Information in C#

    Posted on October 24, 2012 by in Dotnet Tips & Tricks, Tips & Tricks

    We use ManagementObjectSearcher to execute the given query to get the list of management objects that matches the select criteria.  When instantiated, an instance of this class takes as input a WMI query represented in an ObjectQuery and execute the query in. When the Get method on this object is invoked, the ManagementObjectSearcher executes the given query in the specified scope and returns a collection of management objects that match the query.

    public static void RetrieveProcessorInfo()
        //initialize the select query with command text
        SelectQuery query = new SelectQuery(@"Select * from Win32_Processor");
        //initialize the searcher with the query it is supposed to execute
        using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
            //execute the query
            foreach (ManagementObject process in searcher.Get())
                //print process properties
                Console.WriteLine("/*********Processor Information ***************/");
               Console.WriteLine("{0}{1}", "Manufacturer:" , process["Manufacturer"]);
               Console.WriteLine("{0}{1}", "Name:", process["Name"]);
               Console.WriteLine("{0}{1}", "MaxClockSpeed:", process["MaxClockSpeed"]);
               Console.WriteLine("{0}{1}", "ProcessorID:", process["ProcessorID"]);
               Console.WriteLine("{0}{1}", "Revision:", process["Revision"]);

    wmi to get processor information 1

    List of Other Processor Properties

    DataType Name
    uint16 AddressWidth
    uint16 Architecture
    uint16 Availability
    string Caption
    uint32 ConfigManagerErrorCode
    boolean ConfigManagerUserConfig
    uint16 CpuStatus
    string CreationClassName
    uint32 CurrentClockSpeed
    uint16 CurrentVoltage
    uint16 DataWidth
    string Description
    string DeviceID
    boolean ErrorCleared
    string ErrorDescription
    uint32 ExtClock
    uint16 Family
    datetime InstallDate
    uint32 L2CacheSize
    uint32 L2CacheSpeed
    uint32 L3CacheSize
    uint32 L3CacheSpeed
    uint32 LastErrorCode
    uint16 Level
    uint16 LoadPercentage
    string Manufacturer
    uint32 MaxClockSpeed
    string Name
    uint32 NumberOfCores
    uint32 NumberOfLogicalProcessors
    string OtherFamilyDescription
    string PNPDeviceID
    uint16 PowerManagementCapabilities[]
    boolean PowerManagementSupported
    string ProcessorId
    uint16 ProcessorType
    uint16 Revision
    string Role
    string SocketDesignation
    string Status
    uint16 StatusInfo
    string Stepping
    string SystemCreationClassName
    string SystemName
    string UniqueId
    uint16 UpgradeMethod
    string Version
    uint32 VoltageCaps
    uint16 AddressWidth
    Be Sociable, Share!
      Post Tagged with , ,

    Written by

    Software architect with over 10 years of proven experience in designing & developing n-tier and web based software applications, for Finance, Telecommunication, Manufacturing, Internet and other Commercial industries. He believes that success depends on one's ability to integrate multiple technologies to solve a simple as well as complicated problem.

    View all articles by

    Email : [email protected]

    Leave a Reply