Beispiel #1
0
        public void Load(XmlNode node)
        {
            XmlAttribute att = node.Attributes["IP"];

            if (att != null)
            {
                IP = IPAddress.Parse(att.InnerText);
            }


            att = node.Attributes["Mac"];
            if (att != null)
            {
                Mac = new MacInfo(long.Parse(att.InnerText));
            }

            att = node.Attributes["HostName"];
            if (att != null)
            {
                HostName = att.InnerText;
            }
            att = node.Attributes["NickName"];
            if (att != null)
            {
                NickName = att.InnerText;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 获取远程MAC
        /// </summary>
        /// <param name="remoteIP"></param>
        /// <returns></returns>
        public static MacInfo GetRemoteMac(string remoteIP)
        {
            MacInfo info = GetRemoteMacOther(remoteIP);

            if (info.Mac == 0)
            {
                info = GetRemoteMacXP(remoteIP);
            }
            return(info);
        }
Beispiel #3
0
        /// <summary>
        /// 扫描机器
        /// </summary>
        /// <param name="machine"></param>
        private void ScanMachine(object objMachine)
        {
            LanMachine machine = objMachine as LanMachine;

            try
            {
                if (machine.Ping(_speed.Timeout).Status == IPStatus.Success)
                {
                    try
                    {
                        machine.HostName = LanMachine.GetHostName(machine.IP);
                    }
                    catch
                    {
                        machine.HostName = machine.IP.ToString();
                    }
                    try
                    {
                        machine.Mac = MacInfo.GetRemoteMac(machine.IP.ToString());
                    }
                    catch { }
                    AddToGrid(machine, dgMembers);
                }
            }
            catch (Exception ex) { }
            finally
            {
                try
                {
                    if (!this.IsDisposed && !_isStop)
                    {
                        this.Invoke(new MethodInvoker(delegate
                        {
                            tspbScan.Value++;
                            tsProcess.Text = (tspbScan.Value * 100 / tspbScan.Maximum).ToString() + "%";
                            if (tspbScan.Value >= tspbScan.Maximum)
                            {
                                DoScaning(false);
                            }
                        }));
                    }
                }
                catch { }
            }
        }
Beispiel #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     MessageBox.Show(MacInfo.GetRemoteMac("192.168.1.25").ToString());
 }