Disable Proxy In Web Browser
I'm currently using the following code to set a proxy:
Code:
Public Structure Struct_PROXY
Public dwAccessType As Integer
Public proxy As IntPtr
Public pxyby As IntPtr
End Structure
Private Declare Auto Function InternetSetOption Lib "wininet.dll" (ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, ByVal lpdwBufferLength As Integer) As Boolean
Private Sub refreshproxy(ByVal strProxy As String)
Const IOProxy As Integer = 38
Const IProxy As Integer = 3
Dim st_SP As Struct_PROXY
st_SP.dwAccessType = IProxy
st_SP.proxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(strProxy)
st_SP.pxyby = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("Global")
Dim intptrStruct As IntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(st_SP))
System.Runtime.InteropServices.Marshal.StructureToPtr(st_SP, intptrStruct, True)
InternetSetOption(IntPtr.Zero, IOProxy, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(st_SP))
End Sub
to call it I use:
Code:
refreshproxy(IP:PORT)
Setting the proxy works, but I can't seem to figure out how to disable it.
Any help is appreciated.
Re: Disable Proxy In Web Browser
Re: Disable Proxy In Web Browser
Quote:
Originally Posted by
cengineer
Thanks, but I still have the same problem.
I can enable the proxy but it wont disable.
Re: Disable Proxy In Web Browser
Sorry for the bump / double post but I doubt I'm gonna get help with this if it's on the 3rd page.
Does anybody know a solution? :(
Re: Disable Proxy In Web Browser
i know this is old thread but someone might find it useful
Code:
Imports Microsoft.Win32
'
'
'
'
Private Sub disableproxy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles disableproxy.Click
'Connect to the registry and disable the proxy
Dim proxy As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
proxy.SetValue("ProxyEnable", 0)
End Sub