台灣最大程式設計社群網站
線上人數
473
 
會員總數:245785
討論主題:189420
歡迎您免費加入會員
討論區列表 >> 專欄文章 >> 讀取網路卡位址(MAC address)的程式
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
讀取網路卡位址(MAC address)的程式
價值 : 0 QP  點閱數:1010 回應數:0
樓主

站務人員 站長
門外漢
0 1580
542 9
發送站內信

捐贈 VP 給 站務人員
以下為取得Client端IP及MAC Address(網卡號碼)之asp範例

=============================
Get the clients MAC(Media Access Control) address, a hardware address that uniquely identifies each node of a network. Works great on LAN's. Firewalls and Proxy's will be an issue depending what side of them you're coding for.

<%@ LANGUAGE="VBSCRIPT"%>
<%'**************************************
' Name: MAC address
' Description:Get the clients MAC(Media
' Access Control)
'address, a hardware address that uniquely
'identifies Each node of a network. Works great on
'LAN's. Firewalls and Proxy's will be an issue
'depending what side of them you're coding for.
' By: Jerry Aguilar
'
' Returns:Returns the client IP and MAC
' address.
'
' Assumes:You can't navigate to it runni
' ng PWS on the same
'pc but if you are running PWS, you can navigate
'To it from another pc on the same lan (it does
'Not like 127.0.0.1)
'
'This code is copyrighted and has ' limited warranties.Please see http://w
' ww.Planet-Source-Code.com/xq/ASP/txtCode
' Id.6312/lngWId.4/qx/vb/scripts/ShowCode.
' htm 'for details.
'**************************************
%>

<% 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
fso.deletefile "c:\" & strIP & ".txt"
Set fso = nothing
GetMACAddress = macaddress
End function
%>
<HTML>
<HEAD>
<TITLE>Say Hello To the MAC MAN</TITLE>
</HEAD>
<BODY>
<%Response.Write("Your IP is : " & strIP & "<BR>" & vbcrlf)%>
<%Response.Write("Your MAC is : " & strMac & vbcrlf)%>
</BODY>
</HTML>
引述自下列網站
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6312
本篇文章發表於2002-05-27 14:36
目前尚無任何回覆
   

回覆
如要回應,請先登入.