Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential)> _
    Public Structure Struct_INTERNET_PROXY_INFO
     Public dwAccessType As Integer
     Public proxy As IntPtr
     Public proxyBypass As IntPtr
    End Structure

    <DllImport("wininet.dll", SetLastError:=True)> _
    Private Shared Function InternetSetOption( _
     ByVal hInternet As IntPtr, _
     ByVal dwOption As Integer, _
     ByVal lpBuffer As IntPtr, _
     ByVal lpdwBufferLength As Integer) _
     As Boolean
    End Function

    Private Function RefreshIESettings(ByVal strProxy As String) As Boolean
     Dim INTERNET_OPTION_PROXY As Integer = 38
     Dim INTERNET_OPEN_TYPE_PROXY As Integer = 3

     Dim struct_IPI As Struct_INTERNET_PROXY_INFO

     'Filling in structure
     struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY
     struct_IPI.proxy = Marshal.StringToHGlobalAnsi(strProxy)
     struct_IPI.proxyBypass = Marshal.StringToHGlobalAnsi("local")

     'Allocating memory
     Dim intptrStruct As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI))

     'Converting structure to IntPtr
     Marshal.StructureToPtr(struct_IPI, intptrStruct, True)

     Return InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, Marshal.SizeOf(struct_IPI))
    End Function

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 pcman 的頭像
    pcman

    電腦購物天堂

    pcman 發表在 痞客邦 留言(0) 人氣()