• 0

[VB.NET] Setting Internet Explorer Proxy Settings


Question

I have this plugin-based application where one of the plugins, it's supposed to change IE proxy settings. I'm doing this via registry, and all the values are changed according to the real settings. The keys/values I changed are the ones that IE changes when you enable/disable the proxy server as I took screenshots of both the registry states, before and after applying a proxy server.

However, this is not really working. As I said, the values change (to enable or disable depending on what we want) but the checkbox on Internet Explorer settings doesn't change. Well, if the proxy is really enabled and I want to disable it, it works, the checkbox is unmarked, but if the checkbox is not marked and I try to enable it with my code, all values change but the checkbox remains unchecked.

Here's the code:

Public Sub EnableProxy()
		If objHost.DirectConnection = False Then
			Dim regKey As RegistryKey

			regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)

			regKey.SetValue("ProxyEnable", True, RegistryValueKind.DWord)
			regKey.SetValue("ProxyServer", objHost.ProxyAddress.ToString + ":" + objHost.ProxyPort.ToString, RegistryValueKind.String)

			If objHost.BypassLocal Then
				regKey.SetValue("ProxyOverride", "<local>", RegistryValueKind.String)
			Else
				regKey.DeleteValue("ProxyOverride", False)
			End If

			regKey.Close()
		Else
			MessageBox.Show("Networkcher is currently not configured to use a proxy server. " + ControlChars.CrLf + _
							"Please open Network Switcher settings dialog and configure the proxy server.", "Missing proxy settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
		End If
	End Sub

	Public Sub DisableProxy()
		Dim regKey As RegistryKey

		regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)

		regKey.SetValue("ProxyEnable", False, RegistryValueKind.DWord)

		regKey.Close()
	End Sub

I would really appreciate any help on this...

3 answers to this question

Recommended Posts

  • 0
  Nazgulled said:
I have this plugin-based application where one of the plugins, it's supposed to change IE proxy settings. I'm doing this via registry, and all the values are changed according to the real settings. The keys/values I changed are the ones that IE changes when you enable/disable the proxy server as I took screenshots of both the registry states, before and after applying a proxy server.

However, this is not really working. As I said, the values change (to enable or disable depending on what we want) but the checkbox on Internet Explorer settings doesn't change. Well, if the proxy is really enabled and I want to disable it, it works, the checkbox is unmarked, but if the checkbox is not marked and I try to enable it with my code, all values change but the checkbox remains unchecked.

Here's the code:

Public Sub EnableProxy()
		If objHost.DirectConnection = False Then
			Dim regKey As RegistryKey

			regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)

			regKey.SetValue("ProxyEnable", True, RegistryValueKind.DWord)
			regKey.SetValue("ProxyServer", objHost.ProxyAddress.ToString + ":" + objHost.ProxyPort.ToString, RegistryValueKind.String)

			If objHost.BypassLocal Then
				regKey.SetValue("ProxyOverride", "<local>", RegistryValueKind.String)
			Else
				regKey.DeleteValue("ProxyOverride", False)
			End If

			regKey.Close()
		Else
			MessageBox.Show("Networkcher is currently not configured to use a proxy server. " + ControlChars.CrLf + _
							"Please open Network Switcher settings dialog and configure the proxy server.", "Missing proxy settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
		End If
	End Sub

	Public Sub DisableProxy()
		Dim regKey As RegistryKey

		regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)

		regKey.SetValue("ProxyEnable", False, RegistryValueKind.DWord)

		regKey.Close()
	End Sub

I would really appreciate any help on this...

Are you restarting internet explorer before checking for the check box?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.