以下是我网上找的代码能得到同一段IP地址的MAC地址但是不是同一段的就不能得到
我只是需要内网
 string userip = Request.UserHostAddress;
            string strClientIP = Request.UserHostAddress.ToString().Trim();
            Int32 ldest = inet_addr(strClientIP); //目的地的ip 
            Int32 lhost = inet_addr("");   //本地服务器的ip 
            Int64 macinfo = new Int64();
            Int32 len = 6;
            int res = SendARP(ldest, 0, ref macinfo, ref len);
            string mac_src = macinfo.ToString("X");
            if (mac_src == "0")
            {
                if (userip == "127.0.0.1")
                    Label1.Text="正在访问Localhost!";
                else
                    Response.Write("欢迎来自IP为" + userip + "的朋友!" + "<br>");
                return;
            }            while (mac_src.Length < 12)
            {
                mac_src = mac_src.Insert(0, "0");
            }            string mac_dest = "";            for (int i = 0; i < 11; i++)
            {
                if (0 == (i % 2))
                {
                    if (i == 10)
                    {
                        mac_dest = mac_dest.Insert(0, mac_src.Substring(i, 2));
                    }
                    else
                    {
                        mac_dest = "-" + mac_dest.Insert(0, mac_src.Substring(i, 2));
                    }
                }
            }
MacC#

解决方案 »

  1.   

    局域网的应该可以获取到
    http://download.csdn.net/detail/WUNEN/3343734#comment
      

  2.   

    我看了些资料 SendARP这个api不能跨网段获得mac地址
      

  3.   

    有什么办法得到远程计算机的mac地址呢???
    大家帮帮忙啊
      

  4.   

    http://bbs.csdn.net/topics/390139017?page=4#post-394250646
    记下这个网址学习
      

  5.   


        public string GetMac(string clientIp)
        {
            string mac = "";
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo.FileName = "nbtstat";
            process.StartInfo.Arguments = "-a " + clientIp;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.Start();
            string output = process.StandardOutput.ReadToEnd();
            int length = output.IndexOf("MAC Address =");
            if (length > 0)
            {
                mac = output.Substring(length + 14, 17);
            }
            return mac;
            
        }
      

  6.   

    lz学过计算机网络么?mac是数据链路层的地址,不同网段通过ip层的路由和交换机转发数据,哪里还保留mac地址呢。好比你派发一个电报到外地,对方还能知道你提交给电报员的原始电报文是用什么颜色的圆珠笔写的么?
      

  7.   

    其实我知道IP肯定能得到这不是问题,在客户端做个ActiveX空间也能实现mac地址的获得,我就是不知道能不能直接得到mac地址,根据以上大侠的帮助是费劲的
      

  8.   

    同意14楼的,怎么可能能获取mac,这个问题已经被问滥了。。