获取远程电脑CPU的信息(转)

转至:http://topic.csdn.net/u/20080706/22/a45bc851-758c-4f67-b5aa-4962419cbd26.html
using System.Management;
ConnectionOptions oConn = new ConnectionOptions();

            //用户名和口令是你登陆对方是必须输入的,也就是对方给你分配的权限
            oConn.Username = user; //访问对方的用户名
            oConn.Password = password; //访问对方的口令

            try
            {
                // ServerName 是对方机器的名字,也可以是 IP 地址,\root\cimv2 照抄就行
                ManagementPath p = new ManagementPath("\\\\" + ServerName + "\\root\\cimv2");

                ManagementScope ms = new ManagementScope(p, oConn);

                ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_Processor");

                ManagementObjectSearcher query1 = new ManagementObjectSearcher(ms, oq);

                ManagementObjectCollection queryCollection1 = query1.Get();

                //列举所有对像,并显示在 listBox 中
                ListBox3.Items.Clear();
                foreach (ManagementObject Return in queryCollection1)
                {
                    ListBox3.Items.Add("编号:" + Return["DeviceID"] + "");
                    ListBox3.Items.Add("CPU序列号:" + Return["ProcessorId"] + "");
                    ListBox3.Items.Add("CPU状态:" + Return["CpuStatus"] + "");
                    ListBox3.Items.Add("类别:" + Return["Caption"] + "");
                    ListBox3.Items.Add("描述:" + Return["Description"] + "");
                    ListBox3.Items.Add("当前电压:" + Return["CurrentVoltage"] + "");
                    ListBox3.Items.Add("外部频率:" + Return["ExtClock"] + "");
                    ListBox3.Items.Add("二级缓存尺寸:" + Return["L2CacheSize"] + "");
                    ListBox3.Items.Add("二级缓存频率:" + Return["L2CacheSpeed"] + "");
                    ListBox3.Items.Add("制造商名称:" + Return["Manufacturer"] + "");
                    ListBox3.Items.Add("产品名称:" + Return["Name"] + "");
                    ListBox3.Items.Add("版本信息:" + Return["Version"] + "");
                    ListBox3.Items.Add("当前使用百分比:" + Return["LoadPercentage"] + "" + "%");
                    ListBox3.Items.Add("最大时钟频率:" + Return["MaxClockSpeed"] + "");
                    ListBox3.Items.Add("当前时钟频率:" + Return["CurrentClockSpeed"] + "");
                    ListBox3.Items.Add("CPU地址宽度:" + Return["AddressWidth"] + "");
                    ListBox3.Items.Add("CPU数据宽度:" + Return["DataWidth"] + "");
                    //break;
                }
            }
            catch (Exception ex)
            {
                Page.RegisterStartupScript("Alert", " <script language=javascript>alert('连接" + ServerName + "出错,出错信息为:" + ex.Message + "!!'); </script>");
            }

转载于:https://www.cnblogs.com/zyzhang/archive/2008/07/07/1237225.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值