以下是Asp.Net(C#)实现在线检测系统信息的代码,能够轻松获取系统的硬件、系统服务、系统进程等信息。顺便发个测试地址http://www.mycjweb.com/pcinfo.aspx,在线测一测你的系统信息,省去安装系统检测软件的麻烦。不是很强大,有待进一步完善。
\n
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Management;
using System.Collections;
using System.Collections.Specialized;
using System.Text;
using System.Runtime.InteropServices;
\n
public partial class PcInfo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
WMI w;
LabelInfo.Text = LabelInfo.Text + “<font size=’2′ color=’blue’><strong>操作系统</strong></font><br />”;
w = new WMI(WMIPath.Win32_OperatingSystem);
for (int i = 0; i < w.Count; i++)
{
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + w[i, "Caption"].ToString() + “<br />”;
}
\n
\n
LabelInfo.Text = LabelInfo.Text + “<font size=’2′ color=’blue’><strong>时区</strong></font><br />”;
w = new WMI(WMIPath.Win32_TimeZone);
for (int i = 0; i < w.Count; i++)
{
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + w[i, "Caption"].ToString() + “<br />”;
}
\n
LabelInfo.Text = LabelInfo.Text + “<font size=’2′ color=’blue’><strong>主板BIOS</strong></font><br />”;
w = new WMI(WMIPath.Win32_BIOS);
for (int i = 0; i < w.Count; i++)
{
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + w[i, "Caption"].ToString() + “<br />”;
}
\n
LabelInfo.Text = LabelInfo.Text + “<font size=’2′ color=’blue’><strong>系统分区</strong></font><br />”;
w = new WMI(WMIPath.Win32_LogicalDisk);
for (int i = 0; i < w.Count; i++)
{
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + w[i, "Caption"].ToString() + “ ”;
}
\n
LabelInfo.Text = LabelInfo.Text + “<font size=’2′ color=’blue’><strong>虚拟内存</strong></font><br />”;
w = new WMI(WMIPath.Win32_PageFile);
for (int i = 0; i < w.Count; i++)
{
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + w[i, "Caption"].ToString() + “<br />”;
}
LabelInfo.Text = LabelInfo.Text + “<font size=’2′ color=’blue’><strong>网卡及MAC地址</strong></font><br />”;
w = new WMI(WMIPath.Win32_NetworkAdapterConfiguration);
for (int i = 0; i < w.Count; i++)
{
if ((bool)w[i, "IPEnabled"])
{
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + “网卡名称:” + w[i, "Caption"].ToString() + “ ”;
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + “MAC地址:” + w[i, "MACAddress"].ToString() + “<br />”;
}
}
\n
LabelInfo.Text = LabelInfo.Text + “<font size=’2′ color=’blue’><strong>键盘</strong></font><br />”;
w = new WMI(WMIPath.Win32_Keyboard);
for (int i = 0; i < w.Count; i++)
{
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + w[i, "Caption"].ToString() + “<br />”;
}
\n
LabelInfo.Text = LabelInfo.Text + “<font size=’2′ color=’blue’><strong>打印机</strong></font><br />”;
w = new WMI(WMIPath.Win32_Printer);
for (int i = 0; i < w.Count; i++)
{
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + w[i, "Caption"].ToString() + “<br />”;
}
LabelInfo.Text = LabelInfo.Text + “<font size=’2′ color=’blue’><strong>Modem接口</strong></font><br />”;
w = new WMI(WMIPath.Win32_POTSModem);
for (int i = 0; i < w.Count; i++)
{
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + w[i, "Caption"].ToString() + “<br />”;
}
LabelInfo.Text = LabelInfo.Text + “<font size=’2′ color=’blue’><strong>系统驱动</strong></font><br />”;
w = new WMI(WMIPath.Win32_SystemDriver);
for (int i = 0; i < w.Count; i++)
{
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + w[i, "Caption"].ToString() + “<br />”;
}
\n
LabelInfo.Text = LabelInfo.Text + “<font size=’2′ color=’blue’><strong>系统服务</strong></font><br />”;
w = new WMI(WMIPath.Win32_Service);
for (int i = 0; i < w.Count; i++)
{
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + w[i, "Caption"].ToString() + “<br />”;
}
LabelInfo.Text = LabelInfo.Text + “<font size=’2′ color=’blue’><strong>系统进程</strong></font><br />”;
w = new WMI(WMIPath.Win32_Process);
for (int i = 0; i < w.Count; i++)
{
LabelInfo.Text = LabelInfo.Text + “ <img src=’images/menu_arrow.gif’> ” + w[i, "Caption"].ToString() + “<br />”;
}
\n
}
}
\n
来源:http://www.cnblogs.com/jubi2008
\n