标题:如何使用C#获取局域网IP和MAC地址
只看楼主
domon
Rank: 3Rank: 3
来 自:河南
等 级:论坛游侠
帖 子:92
专家分:191
注 册:2009-10-26
得分:0 
不悔,谢谢你啦 嘿嘿
找到解决方法了,贴出来,共享下
public class ComputerAddressInfo
    {
        //ComputerAddressInfo cai = new ComputerAddressInfo("10.25.17",42,53);
         
        private int startIP = 0;
 
        private int endIP = 0;
 
        private string ipPrefix = "";
 
        private ArrayList computerList = null;
 
        public ComputerAddressInfo(string ipPrefix,int startIP,int endIP)
        {
 
            this.startIP = startIP;
 
            this.endIP = endIP;
 
            this.ipPrefix = ipPrefix;
 
            computerList = new ArrayList();
        }
 
        public void ScanComputers()
        {
            for(int i=startIP;i<=endIP;i++)
            {
 
                string scanIP = ipPrefix +"."+i.ToString();
 
                IPAddress myScanIP = IPAddress.Parse(scanIP);
 
                IPHostEntry myScanHost = null;
 
                string[] arr = new string[2];
 
                try
                {
                    myScanHost = Dns.GetHostByAddress(myScanIP);
                }
                catch
                {
                    continue;
                }
 
                if (myScanHost != null)
                {
                    arr[0] = myScanHost.HostName;
 
                    arr[1] = scanIP;
                    Console.WriteLine(arr[0]+"       "+arr[1]);
 
                    computerList.Add(arr);
                }
                 
 
            }
 
        }
 
    }

希望,是走出来的!!!
2009-10-26 16:37
mimirainer
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-11-12
得分:0 
兄弟,可以不可以实现全网检测那些IP地址段的IP在使用和未使用的IP,并获取其使用IP终端的MAC地址?
2013-11-12 10:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-289982-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.581194 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved