帝国软件
  设为首页 加入收藏 关于我们
 
解密帝国网站管理系统
栏 目:
 
您的位置:首页 > 技术文档 > ASP编程
获得客房端的MAC(Media Access Control)地址
作者: 发布时间:2005-03-12 来源:

     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.


  
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!



    '**************************************
    ' for :MAC address
    '**************************************
    This code is AS IS! I had a need For it on a
    project I was working On and found almost no info
    anywhere On what I needed To accomplish. If it
    helps you, great! If it does Not work For you:
    1.Make sure you're Not trying To hit on the same
    pc it's on.
    2.Comment out where the file gets deleted
    (fso.deletefile "c:" & strIP & ".txt"), To view
    some potential Error info.
    3.Have fun debugging :) (I did)


code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!



    '**************************************
    ' 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
    '
    '
    ' Inputs:None
    '
    ' Returns:Returns the client IP and MAC
    '     address.
    '
    'Assumes:You can't navigate to it runnin
    '     g 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)
    '
    'Side Effects:None
    '
    'Warranty:
    'code provided by Planet Source Code(tm)
    '     (www.Planet-Source-Code.com) 'as is', wi
    '     thout warranties as to performance, fitn
    '     ess, merchantability,and any other warra
    '     nty (whether expressed or implied).
    'Terms of Agreement:
    'By using this source code, you agree to
    '     the following terms...
    ' 1) You may use this source code in per
    '     sonal projects and may compile it into a
    '     n .exe/.dll/.ocx and distribute it in bi
    '     nary format freely and with no charge.
    ' 2) You MAY NOT redistribute this sourc
    '     e code (for example to a web site) witho
    '     ut written permission from the original
    '     author.Failure to do so is a violation o
    '     f copyright laws.
    ' 3) You may link to this code from anot
    '     her website, provided it is not wrapped
    '     in a frame.
    ' 4) The author of this code may have re
    '     tained certain additional copyright righ
    '     ts.If so, this is indicated in the autho
    '     r's description.
    '**************************************
    
    <%@ 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
    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>
  
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·获得上一个月几月  (2005-03-12)
 ·用Visual C#获得计算机名称和IP  (2005-03-12)
 ·服务器获得客户端时间的方法  (2005-03-12)
 ·获得消息:J2EE 1.4 中的消息  (2005-03-12)

   栏目导行
  PHP编程
  ASP编程
  ASP.NET编程
  JAVA编程
   站点最新
·致合作伙伴的欢迎信
·媒体报道
·帝国软件合作伙伴计划协议
·DiscuzX2.5会员整合通行证发布
·帝国CMS 7.0版本功能建议收集
·帝国网站管理系统2012年授权购买说
·PHPWind8.7会员整合通行证发布
·[官方插件]帝国CMS-访问统计插件
·[官方插件]帝国CMS-sitemap插件
·[官方插件]帝国CMS内容页评论AJAX分
   类别最新
·在ASP中使用数据库
·使用ASP脚本技术
·通过启动脚本来感受ASP的力量
·学习使用ASP对象和组件
·解析asp的脚本语言
·初看ASP-针对初学者
·ASP开发10条经验总结
·ASP之对象总结
·ASP与数据库应用(给初学者)
·关于学习ASP和编程的28个观点
 
关于帝国 | 广告服务 | 联系我们 | 程序开发 | 网站地图 | 留言板 帝国网站管理系统