private void btnFreeInternet_Click(
            object sender,
            EventArgs e)
        {
            m_bChangedOnce = true;
            var btn = sender as Button;

            btn.Enabled = false;

            foreach (var a in WifiAdapters)
            {
                ChgMac.Randomize(a.Name);
            }

            btn.Enabled = true;

            MessageBox.Show(
                "MAC address of WiFi adapter(s) has been changed!\n\n" +
                "Please reconnect to the Wi-Fi network again!\n" +
                "\n" +
                "Note: When you exit this utility, everything will be reverted back to normal.",
                "Information",
                MessageBoxButtons.OK,
                MessageBoxIcon.Information);
            m_LastTime = DateTime.Now;
        }
 private void Form1_FormClosing(
     object sender,
     FormClosingEventArgs e)
 {
     // Reset adapters MAC addresses if we changed them from this application at least one time.
     if (m_bChangedOnce)
     {
         foreach (var a in WifiAdapters)
         {
             ChgMac.Reset(a.Name);
         }
     }
 }
        private static void Test1()
        {
            ChgMac.Init();
            string o;

            ChgMac.Run("help", out o);
            ChgMac.Run("list", out o);
            ChgMac.ListAdapaters();
            var wf = ChgMac.GetWifiAdapters();

            foreach (var w in wf)
            {
                Console.WriteLine("WiFi adapter Name: {0}", w.Name);
            }

            ChgMac.Randomize(wf[0].Name);
            Console.WriteLine(ChgMac.GetRandomWifiMacAddress());
        }
        private bool InitHelpers()
        {
            //
            // Locate and initialize the script
            //
            if (!ChgMac.Init())
            {
                MessageBox.Show(
                    string.Format(
                        "The script '{0}' is not found!\n" +
                        "Please re-download this utility or download the script from {1}",
                        Consts.SCRIPT_CHGMAC,
                        Consts.SITE_CHGMACSCRIPT
                        ),
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
                return(false);
            }

            //
            // List and remember WiFi adapters
            //
            WifiAdapters = ChgMac.GetWifiAdapters();
            if (WifiAdapters == null || WifiAdapters.Length == 0)
            {
                MessageBox.Show(
                    "No WiFi adapters found!\n" +
                    "\n" +
                    "This program requires a WiFi adapter to run properly. Please try again later.",
                    "Warning",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
                return(false);
            }

            return(true);
        }