Problem Calling Marshal Visual Basic 2012

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Renaldo9301
    New Member
    • May 2016
    • 1

    #1

    Problem Calling Marshal Visual Basic 2012

    Code:
    #Region "Using Proxy"
    <Runtime.Intero pServices.DllIm port("wininet.d ll", SetLastError:=T rue)> _
    Private Shared Function InternetSetOpti on(ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, ByVal lpdwBufferLengt h As Integer) As Boolean
    End Function

    Public Structure Struct_INTERNET _PROXY_INFO
    Public dwAccessType As Integer
    Public proxy As IntPtr
    Public proxyBypass As IntPtr
    End Structure

    Public Sub UseProxy(ByVal strProxy As String)
    Const INTERNET_OPTION _PROXY As Integer = 38
    Const INTERNET_OPEN_T YPE_PROXY As Integer = 3

    Dim struct_IPI As Struct_INTERNET _PROXY_INFO

    struct_IPI.dwAc cessType = INTERNET_OPEN_T YPE_PROXY
    struct_IPI.prox y = Marshal.StringT oHGlobalAnsi(st rProxy)
    struct_IPI.prox yBypass = Marshal.StringT oHGlobalAnsi("l ocal")

    Dim intptrStruct As IntPtr = Marshal.AllocCo TaskMem(Marshal .SizeOf(struct_ IPI))

    Marshal.Structu reToPtr(struct_ IPI, intptrStruct, True)

    Dim iReturn As Boolean = InternetSetOpti on(IntPtr.Zero, INTERNET_OPTION _PROXY, intptrStruct, System.Runtime. InteropServices .Marshal.SizeOf (struct_IPI))
    End Sub
    #End Region
Working...