如题
请大侠们帮帮忙

解决方案 »

  1.   

    private string GetMac()
     7    {
     8        string MAC = "";
     9        ManagementClass MC = new ManagementClass("Win32_NetworkAdapterConfiguration");
    10        ManagementObjectCollection MOC = MC.GetInstances();
    11        foreach (ManagementObject moc in MOC)
    12        {
    13            if (moc["IPEnabled"].ToString() == "True")
    14            {
    15                MAC = moc["MacAddress"].ToString();
    16            }
    17        }
    18        return MAC;
    19    }
    20
    21
    22    public string GetCustomerMac(string IP) //para IP is the client's IP
    23    {
    24        if (IP == "127.0.0.1")
    25        {
    26            return GetMac();
    27        }//"00-04-61-5C-31-52";//00-0F-1F-C6-B2-B3 
    28        else
    29        {
    30            string dirResults = "";
    31            ProcessStartInfo psi = new ProcessStartInfo();
    32            Process proc = new Process();
    33            psi.FileName = "nbtstat";
    34            psi.RedirectStandardInput = false;
    35            psi.RedirectStandardOutput = true;
    36            psi.Arguments = "-A " + IP;
    37            psi.UseShellExecute = false;
    38            proc = Process.Start(psi);
    39            dirResults = proc.StandardOutput.ReadToEnd();
    40            proc.WaitForExit();
    41            dirResults = dirResults.Replace("\r", "").Replace("\n", "").Replace("\t", "");
    42            int i = dirResults.LastIndexOf("=");
    43            dirResults = dirResults.Substring(i + 2, 17);
    44            if (dirResults.IndexOf("本地连接") != -1)
    45            { dirResults = "没有得到mac"; }
    46            return dirResults;
    47        }
    48    }
      

  2.   

    http://topic.csdn.net/u/20081107/23/f94cdc80-1afc-4418-aa99-0da478142af0.html
      

  3.   


    哎,BS的ActiveX插件获取不了Win7下的mac地址哦
      

  4.   

    private string GetIp()
        {
            string strHostName = System.Net.Dns.GetHostName();
            System.Net.IPAddress strAddress = System.Net.Dns.Resolve(strHostName).AddressList[0];
            string strUrl = "http://www.ip138.com/ip2city.asp"; //获得IP的网址了
            Uri uri = new Uri(strUrl);
            System.Net.WebRequest wr = System.Net.WebRequest.Create(uri);
            System.IO.Stream s = wr.GetResponse().GetResponseStream();
            System.IO.StreamReader sr = new System.IO.StreamReader(s, System.Text.Encoding.Default);
            string all = sr.ReadToEnd(); //读取网站的数据
            int i = all.IndexOf("[") + 1;
            string tempip = all.Substring(i, 15);
            string ip = tempip.Replace("]", "").Replace(" ", "");//找出i
            return ip;
        }    private string GetMac()
        {
            string MAC = "";
            ManagementClass MC = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection MOC = MC.GetInstances();
            foreach (ManagementObject moc in MOC)
            {
                if (moc["IPEnabled"].ToString() == "True")
                {
                    MAC = moc["MacAddress"].ToString();
                }
            }
            return MAC;
        }
        public string GetCustomerMac(string IP)
        {
            if (IP == "127.0.0.1")
            {
                return GetMac();
            }
            else
            {
                string dirResults = "";
                ProcessStartInfo psi = new ProcessStartInfo();
                Process proc = new Process();
                psi.FileName = "nbtstat";
                psi.RedirectStandardInput = false;
                psi.RedirectStandardOutput = true;
                psi.Arguments = "-A " + IP;
                psi.UseShellExecute = false;
                proc = Process.Start(psi);
                dirResults = proc.StandardOutput.ReadToEnd();
                proc.WaitForExit();
                dirResults = dirResults.Replace("\r", "").Replace("\n", "").Replace("\t", "");
                int i = dirResults.LastIndexOf("=");
                dirResults = dirResults.Substring(i + 2, 17);
                if (dirResults.IndexOf("本地连接") != -1)
                { dirResults = "没有得到mac"; }
                return dirResults;
            }
        }得不到的。不过还是谢谢了
      

  5.   

    http://topic.csdn.net/u/20090617/11/8f0432b6-84ee-49da-a55f-86b3d343ab8b.html
      

  6.   

    怎么又讨论这个问题了!???默认是得不到客户端的Mac地址的, 客户端一些系统信息  网络是不能获取的, 这是最基本的安全问题。
    除非客户手工修改ie安全性设置,用js吧
      

  7.   


    我一开始用的就是JS的,都启用了
    但是得到的mac地址是空的。
    操作系统是win7
      

  8.   

    还有没有其他真正有效的代码哦,要支持win7系统。
    这方面的答案很多,我试了好多种了,其中用ActiveX控件的那种,win7下获取过来的mac地址都是空的,但是在其他操作系统上就能获取到的。