<a href='http://www.biancheng88.cn/html/2008-11/MAC-15647052.html'>获得客房端的MAC(Media Access Control)地址</a><br><br>
Get the clients <a href="http://www.biancheng88.cn/html/special/2008-11/MAC/" title="MAC" target=_blank><B>MAC</B></a>(Media Access Control) address, a hardware address that uniquely identifies each <br>
node of a network. Works great on LAN's. Firewalls and Proxy's will be an issue depending what side of <br>
them you're coding for. <br>
<br>
<br>
<br>
Can't Copy and Paste this?<br>
Click here for a copy-and-paste friendly version of this code!<br>
<br>
<br>
<br>
'**************************************<br>
' for :<a href="http://www.biancheng88.cn/html/special/2008-11/MAC/" title="MAC" target=_blank><B>MAC</B></a> address<br>
'**************************************<br>
This code is AS IS! I had a need For it on a <br>
project I was working On and found almost no info <br>
anywhere On what I needed To accomplish. If it <br>
helps you, great! If it does Not work For you: <br>
1.Make sure you're Not trying To hit on the same <br>
pc it's on.<br>
2.Comment out where the file gets deleted <br>
(fso.deletefile "c:/" & strIP & ".txt"), To view <br>
some potential Error info.<br>
3.Have fun debugging :) (I did)<br>
<br>
<br>
code:<br>
Can't Copy and Paste this?<br>
Click here for a copy-and-paste friendly version of this code!<br>
<br>
<br>
<br>
'**************************************<br>
' Name: <a href="http://www.biancheng88.cn/html/special/2008-11/MAC/" title="MAC" target=_blank><B>MAC</B></a> address<br>
' Description:Get the clients MAC(Media <br>
' Access Control) <br>
address, a hardware address that uniquely <br>
identifies Each node of a network. Works great on <br>
LAN's. Firewalls and Proxy's will be an issue <br>
depending what side of them you're coding for.<br>
' By: Jerry Aguilar<br>
'<br>
'<br>
' Inputs:None<br>
'<br>
' Returns:Returns the client IP and MAC <br>
' address.<br>
'<br>
'Assumes:You can't navigate to it runnin<br>
' g PWS on the same<br>
pc but If you are running PWS, you can navigate <br>
To it from another pc on the same lan (it does <br>
Not like 127.0.0.1)<br>
'<br>
'Side Effects:None<br>
'<br>
'Warranty:<br>
'code provided by Planet Source Code(tm)<br>
' (www.Planet-Source-Code.com) 'as is', wi<br>
' thout warranties as to performance, fitn<br>
' ess, merchantability,and any other warra<br>
' nty (whether expressed or implied).<br>
'Terms of Agreement:<br>
'By using this source code, you agree to<br>
' the following terms...<br>
' 1) You may use this source code in per<br>
' sonal projects and may compile it into a<br>
' n .exe/.dll/.ocx and distribute it in bi<br>
' nary format freely and with no charge.<br>
' 2) You MAY NOT redistribute this sourc<br>
' e code (for example to a web site) witho<br>
' ut written permission from the original <br>
' author.Failure to do so is a violation o<br>
' f copyright laws.<br>
' 3) You may link to this code from anot<br>
' her website, provided it is not wrapped <br>
' in a frame.<br>
' 4) The author of this code may have re<br>
' tained certain additional copyright righ<br>
' ts.If so, this is indicated in the autho<br>
' r's description.<br>
'**************************************<br>
<br>
<%@ LANGUAGE="VBSCRIPT"%><br>
<%<br>
strIP = Request.ServerVariables("REMOTE_ADDR")<br>
strMac = GetMACAddress(strIP)<br>
strHost = Request.ServerVariables("REMOTE_HOST")<br>
Function GetMACAddress(strIP)<br>
Set net = Server.CreateObject("wscript.network")<br>
Set sh = Server.CreateObject("wscript.shell")<br>
sh.run "%comspec% /c nbtstat -A " & strIP & " > c:/" & strIP & ".txt",0,true<br>
Set sh = nothing<br>
Set fso = createobject("scripting.filesystemobject")<br>
Set ts = fso.opentextfile("c:/" & strIP & ".txt")<br>
macaddress = null<br>
Do While Not ts.AtEndOfStream<br>
data = ucase(trim(ts.readline))<br>
If instr(data,"MAC ADDRESS") Then<br>
macaddress = trim(split(data,"=")(1))<br>
Exit Do<br>
End If<br>
loop<br>
ts.close<br>
Set ts = nothing<br>
fso.deletefile "c:/" & strIP & ".txt"<br>
Set fso = nothing<br>
Get<a href="http://www.biancheng88.cn/html/special/2008-11/MAC/" title="MAC" target=_blank><B>MAC</B></a>Address = macaddress<br>
End Function <br>
%><br>
<HTML><br>
<HEAD><br>
<TITLE>Say Hello To the MAC MAN</TITLE><br>
</HEAD><br>
<BODY><br>
<%Response.Write("Your IP is : " & strIP & "<BR>" & vbcrlf)%><br>
<%Response.Write("Your <a href="http://www.biancheng88.cn/html/special/2008-11/MAC/" title="MAC" target=_blank><B>MAC</B></a> is : " & strMac & vbcrlf)%><br>
</BODY><br>
</HTML> <br>
<br>