在编程的过程中,有时候要遇到获取系统的网卡物理地址,我们知道ASP程序语言是最原始的语言,没有面向对象的语言简单操作,不过asp还是能获取本地网卡的mac地址的,直接上程序,复制下面的程序到,需要调用的位置,用GetMACAddress(“IP”)调用即可。
'
'//函数:获取网卡物理地址
'//参数:GetMACAddress("您获取的IP地址")
'//返回:GetMACAddress()
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
以上子程序,可以放在程序中,专门调用。。