如何用C#設定IE的代理

來源:互聯網
上載者:User

大家好,在上一篇文章中《用C#實現WebProxy 伺服器 》中大家知道了Proxy 伺服器的實現和使用。但是使用上文介紹中的方法每次都要設定很麻煩。所以就有了本文《如何用C#設定IE的代理》我以以把主要源碼貼出,希望給大家協助

 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());
10             rk.Close();
11             Factory.ExecuteNonQuery("update  IP set area='1' where address= '" + str1 + "'");
12             this.dataGridView1.DataSource = Factory.GetDataTable("select * from ip");
13             MessageBox.Show("成功!!!");
14         }
15 
16         private void button4_Click(object sender, EventArgs e)
17         {
18             //開啟註冊表鍵 
19             Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true);
20 
21             //設定代理不可用 
22             rk.SetValue("ProxyEnable", 0);
23             rk.Close();
24             MessageBox.Show("成功!!!");
25         }
26

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.