zoukankan      html  css  js  c++  java
  • 获取局域网内部机器的MAC地址

    [DllImport("Iphlpapi.dll")]
        private static extern int SendARP(Int32 dest, Int32 host, ref Int64 mac, ref Int32 length);
        [DllImport("Ws2_32.dll")]
        private static extern Int32 inet_addr(string ip);

        static private Int64 getremotemac(string localip, string remoteip)
        {

            Int32 ldest = inet_addr(remoteip);   //目的地的ip 
            Int32 lhost = inet_addr(localip);   //本地服务器的ip 

            try
            {
                Int64 macinfo = new Int64();
                Int32 len = 6;
                int res = SendARP(ldest, 0, ref   macinfo, ref   len);
                return macinfo;
            }
            catch (Exception err)
            {
                Console.WriteLine("error:{0}", err.Message);
            }
            return 0;
        }

        private void Page_Load(object sender, System.EventArgs e)
        {
            string userip = Request.UserHostAddress;
            //Int32 ldest = inet_addr(userip); //目的地的ip
            //Int32 lhost = inet_addr(" "); //本地服务器的ip
            this.userinfo.Text = Convert.ToString(getremotemac(" ", userip)) ;
        }

  • 相关阅读:
    BAM部署失败 未能加载”AdomdClient”或它的某一个依赖项。系统找不到指定的文件
    BizTalk Server 事务机制
    TSQL 访问远程数据库并对其数据表进行操作
    BAM门户聚合 – Pivot Table不显示数据
    Find max or min
    SetProperties
    Define
    Form derives from Form
    MWArrayComponent
    JAVA JDK
  • 原文地址:https://www.cnblogs.com/tianguook/p/1944563.html
Copyright © 2011-2022 走看看