示例#1
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 { }
            }
        }
示例#2
0
 private void button1_Click(object sender, EventArgs e)
 {
     MessageBox.Show(MacInfo.GetRemoteMac("192.168.1.25").ToString());
 }