コード例 #1
0
        private void btnSetProxy_Click(object sender, EventArgs e)
        {
            //string proxyStr = combProxyList.Text.Trim();
            string proxyStr = "http://127.0.0.1:" + textBox4.Text;

            IEProxySetting.SetProxy(proxyStr, null);
            var currentProxy = GetProxyServer();

            if (currentProxy == proxyStr && GetProxyStatus())
            {
                lblInfo.Text      = "设置代理:" + proxyStr + "成功!";
                lblInfo.ForeColor = Color.Green;
            }
            else
            {
                if (!GetProxyStatus())
                {
                    lblInfo.Text = "设置代理:" + proxyStr + "代理未启用!";
                }
                else
                {
                    lblInfo.Text = "设置代理:" + proxyStr + "失败,正在使用" + currentProxy + "代理,请重试!";
                }
                lblInfo.ForeColor = Color.Red;
            }
            ShowProxyInfo();
        }
コード例 #2
0
        private void btnDisableProxy_Click(object sender, EventArgs e)
        {
            if (IEProxySetting.UnsetProxy())
            {
                MessageBox.Show("取消完成!");
            }
            else
            {
                MessageBox.Show("取消失败!");
            }

            if (!GetProxyStatus())
            {
                lblInfo.Text      = "取消代理完成!";
                lblInfo.ForeColor = Color.Green;
            }
            else
            {
                lblInfo.Text      = "取消失败,正在使用代理" + GetProxyServer();
                lblInfo.ForeColor = Color.Red;
            }
            ShowProxyInfo();
        }