首页 > 学院 > 开发设计 > 正文

C#获取完整的CPU信息

2019-11-17 04:06:16
字体:
来源:转载
供稿:网友
/*-------------------------------------------

//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
            };
        }

     }
}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表