怎样获得远程客户端物理MAC地址 在.NET--C#编程时,怎样获得远程客户端物理MAC地址,请指教,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我还想用一个html页面得到客户端的文件呢!晕 除非用ActiveX控件了,否则不太可能实现了。因为这样太危险了,万一有人想在客户端执行format c:之类的... declare @ip varchar(15),@sql varchar(1000)--得到ip地址create table #ip(a varchar(200))set @sql='ping '+host_name()+' -a -n 1 -l 1'insert into #ip exec master..xp_cmdshell @sqlselect @ip=left(a,patindex('%:%',a)-1) from(select a=substring(a,patindex('Ping statistics for %:%',a)+20,20)from #ip where a like 'Ping statistics for %:%') a--显示结果select 用户计算机名=host_name(),ip地址=@ipdrop table #ip=============================================================================================create table #(txt varchar(200))insert # exec master..xp_cmdshell 'ipconfig /all'select * from # where ltrim(txt) like 'host name%' or ltrim(txt) like 'ip address%'drop table #--结果/*txt ------------------------------------------------------------ Host Name . . . . . . . . . . . . : Lydia IP Address. . . . . . . . . . . . : 192.168.18.188 IP Address. . . . . . . . . . . . : 192.168.18.168 IP Address. . . . . . . . . . . . : 192.168.18.18(所影响的行数为 4 行)*/ using System.Runtime.InteropServices; [DllImport("Iphlpapi.dll")] private static extern int SendARP(Int32 dest,Int32 host,ref Int64 mac,ref Int32 length); [DllImport("Ws2_32.dll")] private static extern Int32 inet_addr(string ip); static private Int64 getRemoteMAC(string localIP, string remoteIP) { Int32 ldest= inet_addr(remoteIP); //远程主机ip Int32 lhost= inet_addr(localIP); //本机ip try { Int64 macinfo = new Int64(); Int32 len = 6; int res = SendARP(ldest,0, ref macinfo, ref len); return macinfo; } catch(Exception err) { Console.WriteLine("Error:{0}",err.Message); } return 0; } ajax 评论和回复的功能 关于用户控件的事件 我已经制作出了一个页面,想套已经制作好的母模板中,怎么弄呢? 刚学完ASP.Net 想做个项目,不知做什么好 有没有专门的ajax控件? 判断数字和判断数据库(只有10分了,本人结帖迅速。。。) 如何在网页中实现删除硬盘中文件 急,简单问题,解决给分,在线等. 水晶报表如何修改图表的图例标题??? 最新ASP.NET控件集,包括我最新编的6个ASP.NET控件,欢迎大家试用下载... 数据库连接的问题,散分了 asp.net中如何获取ActiveX控件的相关属性值?并在获取后可以提交这些值到服务器端?
因为这样太危险了,万一有人想在客户端执行format c:之类的...
create table #ip(a varchar(200))
set @sql='ping '+host_name()+' -a -n 1 -l 1'
insert into #ip exec master..xp_cmdshell @sqlselect @ip=left(a,patindex('%:%',a)-1) from(
select a=substring(a,patindex('Ping statistics for %:%',a)+20,20)
from #ip where a like 'Ping statistics for %:%') a--显示结果
select 用户计算机名=host_name(),ip地址=@ipdrop table #ip
=============================================================================================create table #(txt varchar(200))
insert # exec master..xp_cmdshell 'ipconfig /all'select * from # where ltrim(txt) like 'host name%' or ltrim(txt) like 'ip address%'drop table #--结果
/*
txt
------------------------------------------------------------
Host Name . . . . . . . . . . . . : Lydia IP Address. . . . . . . . . . . . : 192.168.18.188 IP Address. . . . . . . . . . . . : 192.168.18.168 IP Address. . . . . . . . . . . . : 192.168.18.18
(所影响的行数为 4 行)
*/
private static extern int SendARP(Int32 dest,Int32 host,ref Int64 mac,ref Int32 length);
[DllImport("Ws2_32.dll")]
private static extern Int32 inet_addr(string ip); static private Int64 getRemoteMAC(string localIP, string remoteIP)
{
Int32 ldest= inet_addr(remoteIP); //远程主机ip
Int32 lhost= inet_addr(localIP); //本机ip try
{
Int64 macinfo = new Int64();
Int32 len = 6;
int res = SendARP(ldest,0, ref macinfo, ref len);
return macinfo;
}
catch(Exception err)
{
Console.WriteLine("Error:{0}",err.Message);
}
return 0;
}