C#自动设置IE代理服务器(翻墙软件)代码实现_C#教程-查字典教程网
C#自动设置IE代理服务器(翻墙软件)代码实现
C#自动设置IE代理服务器(翻墙软件)代码实现
发布时间:2016-12-28 来源:查字典编辑
摘要:C#自动设置IE代理服务器代码如下:复制代码代码如下:usingSystem;usingSystem.Collections.Generic...

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("SoftwareMicrosoftWindowsCurrentVersionInternet 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("SoftwareMicrosoftWindowsCurrentVersionInternet 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 Filesgoagent-goagent-f0fabf7localgoagent.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;

}

}

}

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新C#教程学习
    热门C#教程学习
    编程开发子分类