C#获取完整的CPU信息

来源:互联网 发布:大道行知文化传媒 编辑:程序博客网 时间:2024/05/16 16:56

//Author:Tang

//Create Date: 09-09-16

-------------------------------------------*/

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {

        ManagementObjectSearcher s =
            new ManagementObjectSearcher("SELECT * FROM Win32_Processor");   

            // for get all CPU info ,using the get() method of Searcher

           // get() return all CPUs collection
        foreach (ManagementObject cpu in s.Get())
        {
            // show each cpu's Infomation
            foreach (PropertyData pd in cpu.Properties)
            {
                Console.WriteLine(pd.Name+"/"+pd.Type+"/"+pd.Value);

               //show each Propertie's Name, Type and Value of current cpu
            };
        }

     }
}