在ASP中,如何读取电脑的网卡的MAC地址?
设一个投票系统,不读取IP,跟电信一样读取网卡的MAC地址。
------解决方案--------------------这个ASP好象不能,没用过
------解决方案--------------------你确认电信是读mac地址的吗?也许是留cookie?
------解决方案--------------------网上是这样说的,不过我自己试没通过
<%
strIP = Request.ServerVariables( "REMOTE_ADDR ")
strMac = GetMAC(strIP)
Function GetMAC(strIP)
Set net = Server.CreateObject( "wscript.network ")
Set sh = Server.CreateObject( "wscript.shell ")
TempPath= "c:\temp\ " '临时目录
sh.run "%comspec% /c nbtstat -A " & strIP & " > " &TempPath&strIP & ".txt ",0,true
Set sh = nothing
Set fso = createobject( "scripting.filesystemobject ")
Set ts = fso.opentextfile(TempPath&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 TempPath&strIP & ".txt "
Set fso = nothing
GetMAC = macaddress
End Function
%>
<HTML>
<HEAD>
<TITLE> Say Hello To the MAC MAN </TITLE>
</HEAD>
<BODY>
<%Response.Write( "I P: " & strIP & " " & vbcrlf & " <p> ")%>
<%Response.Write( "MAC: " & strMac & vbcrlf)%>
</BODY>
</HTML>
------解决方案--------------------网上说的这个是取服务器的MAC地址....而不是客户端...
这个具体要看设票的程序了.一般服务端是不能直接得到MAC地址的.一定是通过 ActiveX 控件得到. 然后,你只需要弄个小动作,骗过 ActiveX 控件即可....
r u clear???
------解决方案--------------------必须要知道的是, 这是由客户端脚本来完成的功能. 而不是运行于ASP服器端的程序.
<HTML> <HEAD> <TITLE> WMI Scripting HTML </TITLE>
<META http-equiv=Content-Type content= "text/html; charset=gb2312 ">
<SCRIPT language=JScript event= "OnCompleted(hResult,pErrorObject, pAsyncContext) " for=foo>
document.forms[0].txtMACAddr.value=unescape(MACAddr);
document.forms[0].txtIPAddr.value=unescape(IPAddr);
document.forms[0].txtDNSName.value=unescape(sDNSName);
//document.formbar.submit();
</SCRIPT>
<SCRIPT language=JScript event=OnObjectReady(objObject,objAsyncContext) for=foo>
if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined " && objObject.IPEnabled == true)
{
if(objObject.MACAddress != null && objObject.MACAddress != "undefined ")
MACAddr = objObject.MACAddress;
if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined ")
IPAddr = objObject.IPAddress(0);
if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined ")
sDNSName = objObject.DNSHostName;
}
</SCRIPT>
<META content= "Microsoft FrontPage 4.0 " name=GENERATOR> </HEAD>
<BODY>
<OBJECT id=locator classid=CLSID:76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT> </OBJECT>
<OBJECT id=foo classid=CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223> </OBJECT>
<SCRIPT language=JScript>