代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Asp.Net
】
关于探针的研究
作者:
Dezai.CN
/ 发布于
2012/11/6
/
553
<div style="text-align: left;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;">using System;</span></div> <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;">using System.Data; using System.Configuration; using System.Collections; 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.Globalization; using System.ComponentModel; using Microsoft.Win32; using System.IO; using System.Management; using System.Diagnostics; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;">public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //获得本地计算机信息 if (!IsPostBack) { /// <summary> /// 取应用程序路径 /// </summary> <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> 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(); <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> //RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE/Microsoft/Internet Explorer/Version Vector"); //lbIEVer.Text = key.GetValue("IE", "未检测到").ToString(); //lbServerLastStartToNow.Text = ((Environment.TickCount / 0x3e8)/60).ToString() + "分钟"; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> //string[] achDrives = Directory.GetLogicalDrives(); //for (int i = 0; i < Directory.GetLogicalDrives().Length - 1; i++) //{ // lbLogicDriver.Text = lbLogicDriver.Text + achDrives[i].ToString(); //} <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> ////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; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> //lbTest.Text = Server.HtmlEncode(Request.ServerVariables["Server_SoftWare"].ToString()); ////WebService2 web = new WebService2(); ////web.HelloWorld(); //int iy = 1; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> } } //操作远程计算机 protected void Button1_Click(object sender, EventArgs e) { <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> long mb = 1048576; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> //1024x1024 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> //设定生成的WMI所需的所有设置 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> System.Management.ConnectionOptions Conn = new ConnectionOptions(); Conn.EnablePrivileges = true; //设定用于WMI连接操作的用户名 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> Conn.Username = "Administrator"; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> //设定用户的口令 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> Conn.Password = ""; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> //设定用于执行WMI操作的范围 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> System.Management.ManagementScope Ms = new ManagementScope("<a style="color: rgb(51, 102, 153);">////192.168.168.16//root//cimv2</a>", Conn); <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> System.Management.ObjectQuery oq = new System.Management.ObjectQuery("SELECT * FROM Win32_OperatingSystem"); <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> ManagementObjectSearcher query1 = new ManagementObjectSearcher(Ms,oq); ManagementObjectCollection queryCollection1 = query1.Get(); <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> foreach ( ManagementObject mo in queryCollection1 ) { string[] ss={""}; //mo.InvokeMethod("ShutDown", ss); Response.Write(mo.ToString()); } } } <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> //try //{ <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // //连接到实际操作的WMI范围 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // Ms.Connect(); <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // //设定通过WMI要查询的内容 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // ObjectQuery Query = new ObjectQuery("select FreeSpace ,Size ,Name from Win32_LogicalDisk where DriveType=3"); <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // //WQL语句,设定的WMI查询内容和WMI的操作范围,检索WMI对象集合 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // ManagementObjectSearcher Searcher = new ManagementObjectSearcher(Ms, Query); <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // //异步调用WMI查询 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // ManagementObjectCollection ReturnCollection = Searcher.Get(); <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // double free = 0; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // double use = 0; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // double total = 0; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // //listBox1.Items.Clear(); <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // //通过对产生的WMI的实例集合进行检索,获得硬盘信息 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // foreach (ManagementObject Return in ReturnCollection) // { // Label1.Text = "磁盘名称:" + Return["Name"].ToString(); // //listBox1.Items.Add("磁盘名称:" + Return["Name"].ToString()); <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // //获得硬盘的可用空间 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // free = Convert.ToInt64(Return["FreeSpace"]) / mb; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // //获得硬盘的已用空间 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // use = (Convert.ToInt64(Return["Size"]) - Convert.ToInt64(Return["FreeSpace"])) / mb; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // //获得硬盘的合计空间 <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // total = Convert.ToInt64(Return["Size"]) / mb; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // //listBox1.Items.Add ( " 总计:"+ total.ToString ( ) + "MB"; <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // } //} //catch (Exception ee) //{ <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> // //MessageBox.Show("连接" + textBox1.Text + "出错,出错信息为:" + ee.Message, "出现错误!"); <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> //} <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> //} //} <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;">ASPX代码: <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"><%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" style="color: rgb(51, 102, 153); text-decoration: initial;">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"> <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"><html xmlns="<a href="http://www.w3.org/1999/xhtml" style="color: rgb(51, 102, 153); text-decoration: initial;">http://www.w3.org/1999/xhtml</a>" > <head id="Head1" runat="server"> <title>Asp.net探针 |— 51aspx.com</title> <style type="text/css"> BODY { FONT-SIZE: 12px; COLOR: #000000 } TABLE { FONT-SIZE: 12px; COLOR: #000000 } TD { FONT-SIZE: 12px; COLOR: #000000 } FORM { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px } TD TD { PADDING-LEFT: 12px } A { COLOR: #000090 } A:hover { COLOR: #ff3333 } .InputTxt { BORDER-RIGHT: #333333 1px solid; BORDER-TOP: #333333 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #333333 1px solid; WIDTH: 120px; BORDER-BOTTOM: #333333 1px solid; HEIGHT: 18px } .Button { BORDER-RIGHT: #333333 1px solid; BORDER-TOP: #333333 1px solid; FONT-SIZE: 12px; BACKGROUND: #ffffff; BORDER-LEFT: #333333 1px solid; WIDTH: 32px; BORDER-BOTTOM: #333333 1px solid; HEIGHT: 16px } .TrHead { FONT-WEIGHT: 600; FONT-SIZE: 12px; BACKGROUND: #339900; COLOR: #ffffff; HEIGHT: 28px; TEXT-ALIGN: center } </style> </head> <body> <form id="form1" runat="server"> <table width="100%" align="center" border="0"> <tr> <td style="FONT-WEIGHT: 600; FONT-SIZE: 16px; COLOR: #339900; height: 11px;" align="center"><a href="<a href="http://www.51aspx.com/" style="color: rgb(51, 102, 153); text-decoration: initial;">http://www.51aspx.com</a>" target="_blank"> <h1> Asp.Net 探针</h1> </a> </td> </tr> </table> <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" style="width: 747px"> <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%" align="left" style="HEIGHT: 8px">逻辑驱动器</td> <td align="left" style="HEIGHT: 8px"> <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> <tr> <td align="left" style="height: 29px"> 当前测试</td> <td align="left" style="height: 29px"> <asp:Label ID="lbTest" runat="server" ></asp:Label></td> </tr> </table> <BR> <table width="95%" border="0"> <tr> <td align="center" class="TrHead"> Asp.net探针</tr> </table> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Label ID="Label1" runat="server" Text="Label" Width="253px"></asp:Label> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></td> </tr> </table> <p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; text-align: left;"> </form> </body> </html>
试试其它关键字
探针
同语言下
.
gzip压缩
.
实现http多线程断点续传下载文件
.
实现多线程断点续传下载大文件
.
生成字符串的 CheckSum
.
根据 UserAgent 获取浏览器的类型和版本
.
根据 Agent 判断是否是智能手机
.
隐藏手机号中间四位为*方法
.
合并图片(二维码和其他图片合并)
.
ASP.NET CORE中判断是否移动端打开网页
.
ASP.NET(C#)实现页面计时(定时)自动跳转
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3