示例#1
0
        private void btnStopSharing_Click(object sender, EventArgs e)
        {
            // Stop connection sharing
            DisableInternetSharing();

            // Stop hosted network
            ToolHelper.StopAp();

            MessageBox.Show("Stopped sharing!");
        }
示例#2
0
        private void btnStartSharing_Click(object sender, EventArgs e)
        {
            string ApName;

            if (!uiValidateApName(out ApName))
            {
                return;
            }

            string Pass;

            if (!uiValidateApPassword(out Pass))
            {
                return;
            }

            // Stop previous hosted network
            ToolHelper.StopAp();

            // Start hosted network
            string output;

            if (!ToolHelper.StartAp(ApName, Pass, out output))
            {
                MessageBox.Show("Failed to start hosted network!");
                return;
            }

            string HostedId = FindHostedNetworkId();

            if (string.IsNullOrEmpty(HostedId))
            {
                MessageBox.Show(
                    "Could not find the hosted network virtual network interface!",
                    "Something went wrong!");
                return;
            }

            bool bOk = EnableInternetSharing(
                cbSourceNetworks.Text,
                HostedId,
                true);

            if (bOk)
            {
                MessageBox.Show("Congratulations! The connection is successfully shared!", "Info");
                return;
            }
        }