<%@ LANGUAGE="VBSCRIPT"%>
<%
strIP = Request.ServerVariables("REMOTE_ADDR")
strMac = GetMACAddress(strIP)
strHost = Request.ServerVariables("REMOTE_HOST")
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
Set fso = nothing
GetMACAddress = macaddress
End Function
%>
<HTML>
<HEAD>
<TITLE>通过ASP获取MAC地址的方法</TITLE>
</HEAD>
<BODY>
<%Response.Write("您机器的IP是: " & strIP & "<BR>" & vbcrlf)%>
<%Response.Write("您机器的MAC地址是: " & strMac & vbcrlf)%>
</BODY>
</HTML>
通过ASP获取MAC地址的方法
未经允许不得转载:小叶白龙博客 » 通过ASP获取MAC地址的方法
评论前必须登录!
注册