Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();
            Control.CheckForIllegalCrossThreadCalls    = false;
            Thread.CurrentThread.IsBackground          = true;
            ServicePointManager.DefaultConnectionLimit = 500;
            string retMac = getLocalMac();

            if (!String.IsNullOrEmpty(retMac))
            {
                this.MACIP = retMac;
                string[] s_arr = this.MACIP.Split(new char[]
                {
                    ':'
                });
                this.MACIP = s_arr[0];
                for (int i = 1; i < s_arr.Length; i++)
                {
                    this.MACIP = this.MACIP + "-" + s_arr[i];
                }
            }
            this.List_sever_ip = ReadXML.readtext();
            this.startTime     = DateTime.MinValue;
            this.stopTime      = DateTime.MinValue;
            this.LUYOU_MAC     = GetLuYouMac.GetMac(ReadXML.readMcaMsg());
            this.YOUXIAN_IP    = GetLuYouMac.GettrueIpV4();
        }
Ejemplo n.º 2
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            this.LUYOU_MAC  = GetLuYouMac.GetMac(ReadXML.readMcaMsg());
            this.YOUXIAN_IP = GetLuYouMac.GettrueIpV4();
            string retMac = getLocalMac();

            if (!String.IsNullOrEmpty(retMac))
            {
                this.MACIP = retMac;
                string[] s_arr = this.MACIP.Split(new char[]
                {
                    ':'
                });
                this.MACIP = s_arr[0];
                for (int i = 1; i < s_arr.Length; i++)
                {
                    this.MACIP = this.MACIP + "-" + s_arr[i];
                }
            }
        }
Ejemplo n.º 3
0
        public string getLocalMac()
        {
            string                     mac             = null;
            ManagementClass            query           = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection queryCollection = query.GetInstances();

            using (ManagementObjectCollection.ManagementObjectEnumerator enumerator = queryCollection.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ManagementObject mo = (ManagementObject)enumerator.Current;
                    if (mo["IPEnabled"].ToString() == "True")
                    {
                        if (GetLuYouMac.isVialdNetCardName(mo["Description"].ToString()))
                        {
                            mac = mo["MacAddress"].ToString();
                            Time_Dates.TimeDates.WriteErroTOLog("Your mac address is " + mac);
                        }
                    }
                }
            }
            return(mac);
        }