当前位置: 移动技术网 > IT编程>开发语言>c# > C#自动设置IE代理服务器(翻墙软件)代码实现

C#自动设置IE代理服务器(翻墙软件)代码实现

2019年07月18日  | 移动技术网IT编程  | 我要评论

c#自动设置ie代理服务器代码如下:

复制代码 代码如下:

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.text;

using system.windows.forms;

using microsoft.win32;

using system.diagnostics;

 

namespace ie

{

    public partial class form1 : form

    {

        public form1()

        {

            initializecomponent();

        }

 

        private void mycheck()//通过读取注册表内"proxyenable"的值,确定程序启动时button1.text的值.

        {

            registrykey mykey = registry.currentuser.opensubkey("software\\microsoft\\windows\\currentversion\\internet settings", true);

            string myget = mykey.getvalue("proxyenable").tostring();

            if (myget == "0")//确定当前状态是启用还是禁用.

            {

                button1.text = "已关闭";

            }

            else

            {

                button1.text = "已打开";

            }

        }

 

        private void button1_click(object sender, eventargs e)

        {

            registrykey mykey = registry.currentuser.opensubkey("software\\microsoft\\windows\\currentversion\\internet settings", true);

 

            if (button1.text == "已打开")// 关闭

            {

                mykey.setvalue("proxyenable", 0x0);

                mykey.setvalue("proxyserver", "");

                button1.text = "已关闭";//关闭goagent按钮不可用,防止程序出错.

            }

            else//打开

            {

                mykey.setvalue("proxyenable", 0x1);

                mykey.setvalue("proxyserver", "127.0.0.1:8087");

                button1.text = "已打开";

            }

        }

 

        private void form1_load(object sender, eventargs e)

        {

            mycheck();

            button3.enabled = false;

        }

 

        private void button2_click(object sender, eventargs e)//打开goagent

        {

            process.start("d:\\program files\\goagent-goagent-f0fabf7\\local\\goagent.exe");

            button2.enabled = false;

            button3.enabled = true;

        }

 

        private void button3_click(object sender, eventargs e)//关闭goagent

        {

            process.getprocessesbyname("goagent")[0].kill();

            process.getprocessesbyname("python27")[0].kill();

            button2.enabled = true;

            button3.enabled = false;

        }

    }

}

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网