转至: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