For the relevant code, refer to the following:
1 private void button3_Click (object sender, EventArgs e)
2 {
3 // open the registry key
4 Microsoft. Win32.RegistryKey rk = Microsoft. Win32.Registry. CurrentUser. OpenSubKey (@ "SoftwareMicrosoftWindowsCurrentVersionInternet Settings", true );
5
6 // set proxy availability
7 rk. SetValue ("ProxyEnable", 1 );
8 // set the proxy IP address and port
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 ("Successful !!! ");
14}
15
16 private void button4_Click (object sender, EventArgs e)
17 {
18 // open the registry key
19 Microsoft. Win32.RegistryKey rk = Microsoft. Win32.Registry. CurrentUser. OpenSubKey (@ "SoftwareMicrosoftWindowsCurrentVersionInternet Settings", true );
20
21 // set proxy unavailable
22 rk. SetValue ("ProxyEnable