以下是ASP.NET(C#)实现在线检测系统信息的代码,能够轻松获取系统的硬件、系统服务、系统进程等信息。顺便发个测试地址http://www.mycjweb.com/pcinfo.aspx,在线测一测你的系统信息,省去安装系统检测软件的麻烦。不是很强大,有待进一步完善。
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;
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 />";
}
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 />";
}
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 />";
}
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() + " ";
}
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 />";
}
}
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 />";
}
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 />";
}
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 />";
}
}
}
以下是ASP.NET(C#)实现在线检测系统信息的代码,能够轻松获取系统的硬件、系统服务、系统进程等信息。顺便发个测试地址http://www.mycjweb.com/pcinfo.aspx,在线测一测你的系统信息,省去安装系统检测软件的麻烦。不是很强大,有待进一步完善。 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; public partial class PcInfo : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { WMI w; LabelInfo.Text = LabelInfo.Text + "操作系统
"; w = new WMI(WMIPath.Win32_OperatingSystem); for (int i = 0; i < w.Count; i++) { LabelInfo.Text = LabelInfo.Text + " " + w[i, "Caption"].ToString() + "
"; } LabelInfo.Text = LabelInfo.Text + "时区
"; w = new WMI(WMIPath.Win32_TimeZone); for (int i = 0; i < w.Count; i++) { LabelInfo.Text = LabelInfo.Text + " " + w[i, "Caption"].ToString() + "
"; } LabelInfo.Text = LabelInfo.Text + "主板BIOS
"; w = new WMI(WMIPath.Win32_BIOS); for (int i = 0; i < w.Count; i++) { LabelInfo.Text = LabelInfo.Text + " " + w[i, "Caption"].ToString() + "
"; } LabelInfo.Text = LabelInfo.Text + "系统分区
"; w = new WMI(WMIPath.Win32_LogicalDisk); for (int i = 0; i < w.Count; i++) { LabelInfo.Text = LabelInfo.Text + " " + w[i, "Caption"].ToString() + " "; } LabelInfo.Text = LabelInfo.Text + "虚拟内存
"; w = new WMI(WMIPath.Win32_PageFile); for (int i = 0; i < w.Count; i++) { LabelInfo.Text = LabelInfo.Text + " " + w[i, "Caption"].ToString() + "
"; } LabelInfo.Text = LabelInfo.Text + "网卡及MAC地址
"; w = new WMI(WMIPath.Win32_NetworkAdapterConfiguration); for (int i = 0; i < w.Count; i++) { if ((bool)w[i, "IPEnabled"]) { LabelInfo.Text = LabelInfo.Text + " " + "网卡名称:" + w[i, "Caption"].ToString() + " "; LabelInfo.Text = LabelInfo.Text + " " + "MAC地址:" + w[i, "MACAddress"].ToString() + "
"; } } LabelInfo.Text = LabelInfo.Text + "键盘
"; w = new WMI(WMIPath.Win32_Keyboard); for (int i = 0; i < w.Count; i++) { LabelInfo.Text = LabelInfo.Text + " " + w[i, "Caption"].ToString() + "
"; } LabelInfo.Text = LabelInfo.Text + "打印机
"; w = new WMI(WMIPath.Win32_Printer); for (int i = 0; i < w.Count; i++) { LabelInfo.Text = LabelInfo.Text + " " + w[i, "Caption"].ToString() + "
"; } LabelInfo.Text = LabelInfo.Text + "Modem接口
"; w = new WMI(WMIPath.Win32_POTSModem); for (int i = 0; i < w.Count; i++) { LabelInfo.Text = LabelInfo.Text + " " + w[i, "Caption"].ToString() + "
"; } LabelInfo.Text = LabelInfo.Text + "系统驱动
"; w = new WMI(WMIPath.Win32_SystemDriver); for (int i = 0; i < w.Count; i++) { LabelInfo.Text = LabelInfo.Text + " " + w[i, "Caption"].ToString() + "
"; } LabelInfo.Text = LabelInfo.Text + "系统服务
"; w = new WMI(WMIPath.Win32_Service); for (int i = 0; i < w.Count; i++) { LabelInfo.Text = LabelInfo.Text + " " + w[i, "Caption"].ToString() + "
"; } LabelInfo.Text = LabelInfo.Text + "系统进程
"; w = new WMI(WMIPath.Win32_Process); for (int i = 0; i < w.Count; i++) { LabelInfo.Text = LabelInfo.Text + " " + w[i, "Caption"].ToString() + "
"; } } }