当前位置:开发者网络 >> 技术教程 >> ASP教程 >> 客户端相关 >> 内容
精彩推荐
分类最新教程
分类热点教程
  
怎樣獲取客戶端ip及mac地址?
作者:未知
日期:2005-09-19
人气:
投稿:(转贴)
来源:未知
字体:
收藏:加入浏览器收藏
以下正文:
獲取ip userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR") If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR") hostname=Request.ServerVariables("HTTP_HOST") 取得mac地址 mac=GetMACAddress(userip) Function GetMACAddress(strIP) Set net = Server.CreateObject("wscript.network") Set sh = Server.CreateObject("wscript.shell") sh.run "%comspec% /c nbtstat -A " & strIP & " > c:\" & strIP & ".txt",0,true Set sh = nothing Set fso = createobject("scripting.filesystemobject") Set ts = fso.opentextfile("c:\" & strIP & ".txt") macaddress = null Do While Not ts.AtEndOfStream data = ucase(trim(ts.readline)) If instr(data,"MAC ADDRESS") Then macaddress = trim(split(data,"=")(1)) Exit Do End If loop ts.close Set ts = nothing fso.deletefile "c:\" & strIP & ".txt" Set fso = nothing GetMACAddress = macaddress End Function
相关文章: