您的位置:首页 > 编程语言 > C#

如何用C#设置IE的代理

2011-04-29 13:56 274 查看
1 private void button3_Click(object sender, EventArgs e)
2 {
3 //打开注册表键
4 Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true);
5
6 //设置代理可用
7 rk.SetValue("ProxyEnable", 1);
8 //设置代理IP和端口
9 rk.SetValue("ProxyServer", this.textBox1.Text.ToString() + ":" + this.textBox2.Text.ToString());
rk.Close();
Factory.ExecuteNonQuery("update IP set area='1' where address= '" + str1 + "'");
this.dataGridView1.DataSource = Factory.GetDataTable("select * from ip");
MessageBox.Show("成功!!!");
}

private void button4_Click(object sender, EventArgs e)
{
//打开注册表键 www.elivn.com
Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true);

//设置代理不可用
rk.SetValue("ProxyEnable", 0);
rk.Close();
MessageBox.Show("成功!!!");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: