如何取得关于里的系统信息?
就像打开vs里的帮助--> 关于 Microsoft.... 画面后的 "系统信息 "的功能,如何实现?????
[解决办法]
<table style= "FONT-SIZE: 12px; COLOR: black; FONT-FAMILY: Verdana, Tahoma; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: whitesmoke "
borderColor= "#666666 " cellSpacing= "0 " width= "760 " align= "center " bgColor= "#eeeeee "
border= "1 ">
<tr>
<td align= "center ">
<table style= "BORDER-COLLAPSE: collapse " borderColor= "#ffffff " cellSpacing= "0 " width= "95% "
align= "center " border= "1 ">
<tr>
<td class= "TrHead " colSpan= "2 " style= "HEIGHT: 21px "> 服务器基本信息 </td>
</tr>
<tr>
<td width= "38% " align= "left " style= "height: 29px "> 服务器计算机名 </td>
<td align= "left " style= "height: 29px ">
<asp:Label ID= "lbServerName " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td height= "26 " align= "left "> 服务器IP地址 </td>
<td align= "left ">
<asp:Label ID= "lbIp " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td height= "26 " align= "left "> 服务器域名 </td>
<td align= "left "> <asp:Label ID= "lbDomain " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td height= "27 " align= "left " style= "HEIGHT: 27px "> 服务器端口 </td>
<td align= "left " style= "HEIGHT: 27px "> <asp:Label ID= "lbPort " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td height= "26 " align= "left "> 服务器IIS版本 </td>
<td align= "left ">
<asp:Label ID= "lbIISVer " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td height= "24 " align= "left " style= "HEIGHT: 24px ">
本文件所在文件夹 </td>
<td align= "left " style= "HEIGHT: 24px ">
<asp:Label ID= "lbPhPath " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td height= "26 " align= "left "> 服务器操作系统 </td>
<td align= "left ">
<asp:Label ID= "lbOperat " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td height= "26 " align= "left ">
系统所在文件夹 </td>
<td align= "left ">
<asp:Label ID= "lbSystemPath " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td height= "26 " align= "left "> 服务器脚本超时时间 </td>
<td align= "left ">
<asp:Label ID= "lbTimeOut " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td height= "26 " align= "left "> 服务器的语言种类 </td>
<td align= "left ">
<asp:Label ID= "lbLan " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td height= "27 " align= "left " style= "HEIGHT: 27px "> .NET Framework 版本 </td>
<td align= "left " style= "HEIGHT: 27px ">
<asp:Label ID= "lbAspnetVer " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td align= "left " style= "height: 29px "> 服务器当前时间 </td>
<td align= "left " style= "height: 29px ">
<asp:Label ID= "lbCurrentTime " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td height= "26 " align= "left ">
服务器IE版本 </td>
<td align= "left ">
<asp:Label ID= "lbIEVer " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td height= "26 " align= "left "> 服务器上次启动到现在已运行 </td>
<td align= "left ">
<asp:Label ID= "lbServerLastStartToNow " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td width= "38% " height= "4 " align= "left " style= "HEIGHT: 4px "> 逻辑驱动器 </td>
<td align= "left " style= "HEIGHT: 4px ">
<asp:Label ID= "lbLogicDriver " runat= "server "> </asp:Label> </td>
</tr>
<TR>
<TD height= "26 " align= "left "> CPU 总数 </TD>
<TD align= "left ">
<asp:Label ID= "lbCpuNum " runat= "server "> </asp:Label> </TD>
</TR>
<tr>
<td height= "26 " align= "left ">
CPU 类型 </td>
<td align= "left ">
<asp:Label ID= "lbCpuType " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td align= "left " style= "height: 29px ">
虚拟内存 </td>
<td align= "left " style= "height: 29px ">
<asp:Label ID= "lbMemory " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td align= "left " style= "height: 29px ">
当前程序占用内存 </td>
<td align= "left " style= "height: 29px ">
<asp:Label ID= "lbMemoryPro " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td align= "left " style= "height: 29px ">
Asp.net所占内存 </td>
<td align= "left " style= "height: 29px ">
<asp:Label ID= "lbMemoryNet " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td align= "left " style= "height: 29px ">
Asp.net所占CPU </td>
<td align= "left " style= "height: 29px ">
<asp:Label ID= "lbCpuNet " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td align= "left " style= "height: 29px ">
当前Session数量 </td>
<td align= "left " style= "height: 29px ">
<asp:Label ID= "lbSessionNum " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td align= "left " style= "height: 29px ">
当前SessionID </td>
<td align= "left " style= "height: 29px ">
<asp:Label ID= "lbSession " runat= "server "> </asp:Label> </td>
</tr>
<tr>
<td align= "left " style= "height: 29px ">
当前系统用户名 </td>
<td align= "left " style= "height: 29px ">
<asp:Label ID= "lbUser " runat= "server "> </asp:Label> </td>
</tr>
</table>
[解决办法]
lbServerName.Text= "http:// " + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;
lbIp.Text = Request.ServerVariables[ "LOCAl_ADDR "];
lbDomain.Text = Request.ServerVariables[ "SERVER_NAME "].ToString();
lbPort.Text = Request.ServerVariables[ "Server_Port "].ToString();
lbIISVer.Text = Request.ServerVariables[ "Server_SoftWare "].ToString();
lbPhPath.Text = Request.PhysicalApplicationPath;
lbOperat.Text = Environment.OSVersion.ToString();
lbSystemPath.Text = Environment.SystemDirectory.ToString();
lbTimeOut.Text = (Server.ScriptTimeout/1000).ToString() + "秒 ";
lbLan.Text = CultureInfo.InstalledUICulture.EnglishName;
lbAspnetVer.Text = string.Concat(new object[] { Environment.Version.Major, ". ", Environment.Version.Minor, Environment.Version.Build, ". ", Environment.Version.Revision });
lbCurrentTime.Text = DateTime.Now.ToString();
RegistryKey key = Registry.LocalMachine.OpenSubKey(@ "SOFTWARE\Microsoft\Internet Explorer\Version Vector ");
lbIEVer.Text = key.GetValue( "IE ", "未检测到 ").ToString();
lbServerLastStartToNow.Text = ((Environment.TickCount / 0x3e8)/60).ToString() + "分钟 ";
string[] achDrives = Directory.GetLogicalDrives();
for (int i = 0; i < Directory.GetLogicalDrives().Length - 1; i++)
{
lbLogicDriver.Text = lbLogicDriver.Text + achDrives[i].ToString();
}
//ManagementClass diskClass = new ManagementClass( "NUMBER_OF_PROCESSORS ");
lbCpuNum.Text = Environment.GetEnvironmentVariable( "NUMBER_OF_PROCESSORS ").ToString();
lbCpuType.Text = Environment.GetEnvironmentVariable( "PROCESSOR_IDENTIFIER ").ToString();
lbMemory.Text = (Environment.WorkingSet / 1024).ToString()+ "M ";
lbMemoryPro.Text = ((Double)GC.GetTotalMemory(false) / 1048576).ToString( "N2 ") + "M ";
lbMemoryNet.Text = ((Double)Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString( "N2 ") + "M ";
lbCpuNet.Text = ((TimeSpan)Process.GetCurrentProcess().TotalProcessorTime).TotalSeconds.ToString( "N0 ");
lbSessionNum.Text = Session.Contents.Count.ToString();
lbSession.Text = Session.Contents.SessionID;
lbUser.Text = Environment.UserName;
这是一个探针程序,自己研究一下吧