C automatically sets up IE proxy server (over the wall software) code implementation
- 2020-05-24 06:00:04
- OfStack
C# automatically sets IE proxy server code as follows:
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()// By reading inside the registry "ProxyEnable" The value of the , Determine when the program starts button1.text The value of the .
{
RegistryKey mykey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
string myget = mykey.GetValue("ProxyEnable").ToString();
if (myget == "0")// Determines whether the current state is enabled or disabled .
{
button1.Text = " closed ";
}
else
{
button1.Text = " Has been opened ";
}
}
private void button1_Click(object sender, EventArgs e)
{
RegistryKey mykey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
if (button1.Text == " Has been opened ")// Shut down
{
mykey.SetValue("ProxyEnable", 0x0);
mykey.SetValue("ProxyServer", "");
button1.Text = " closed ";// Shut down goagent Button not available , Prevent program error .
}
else// Open the
{
mykey.SetValue("ProxyEnable", 0x1);
mykey.SetValue("ProxyServer", "127.0.0.1:8087");
button1.Text = " Has been opened ";
}
}
private void Form1_Load(object sender, EventArgs e)
{
mycheck();
button3.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)// Open the 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)// Shut down goagent
{
Process.GetProcessesByName("goagent")[0].Kill();
Process.GetProcessesByName("python27")[0].Kill();
button2.Enabled = true;
button3.Enabled = false;
}
}
}