Use Proxies


SUBMITTED BY: Guest

DATE: Dec. 7, 2013, 6:53 a.m.

FORMAT: Text only

SIZE: 1.4 kB

HITS: 916

  1. <Runtime.InteropServices.DllImport("wininet.dll", SetLastError:=True)> _
  2. Private Shared Function InternetSetOption(ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, ByVal lpdwBufferLength As Integer) As Boolean
  3. End Function
  4. Public Structure Struct_INTERNET_PROXY_INFO
  5. Public dwAccessType As Integer
  6. Public proxy As IntPtr
  7. Public proxyBypass As IntPtr
  8. End Structure
  9. Private Sub RefreshIESettings(ByVal strProxy As String)
  10. Const INTERNET_OPTION_PROXY As Integer = 38
  11. Const INTERNET_OPEN_TYPE_PROXY As Integer = 3
  12. Dim struct_IPI As Struct_INTERNET_PROXY_INFO
  13. ' Filling in structure
  14. struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY
  15. struct_IPI.proxy = Marshal.StringToHGlobalAnsi(strProxy)
  16. struct_IPI.proxyBypass = Marshal.StringToHGlobalAnsi("local")
  17. ' Allocating memory
  18. Dim intptrStruct As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI))
  19. ' Converting structure to IntPtr
  20. Marshal.StructureToPtr(struct_IPI, intptrStruct, True)
  21. Dim iReturn As Boolean = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))
  22. End Sub

comments powered by Disqus