Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 同时在不同的Web浏览器上使用不同的代理_Vb.net_Visual Studio 2010_Visual Studio_Proxy - Fatal编程技术网

Vb.net 同时在不同的Web浏览器上使用不同的代理

Vb.net 同时在不同的Web浏览器上使用不同的代理,vb.net,visual-studio-2010,visual-studio,proxy,Vb.net,Visual Studio 2010,Visual Studio,Proxy,作为标题,我想知道是否有一种方法可以同时在不同的WebBrowser上使用不同的代理。 首先,我尝试插入5个WebBrowser并创建5个线程,每个线程执行我在internet上找到的用于更改代理的子线程: Public Structure Struct_INTERNET_PROXY_INFO Public dwAccessType As Integer Public proxy As IntPtr Public proxyBypass As IntPtr End Str

作为标题,我想知道是否有一种方法可以同时在不同的WebBrowser上使用不同的代理。 首先,我尝试插入5个WebBrowser并创建5个线程,每个线程执行我在internet上找到的用于更改代理的子线程:

Public Structure Struct_INTERNET_PROXY_INFO
    Public dwAccessType As Integer
    Public proxy As IntPtr
    Public proxyBypass 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 RefreshIESettings(ByVal strProxy As String)
    Const INTERNET_OPTION_PROXY As Integer = 38
    Const INTERNET_OPEN_TYPE_PROXY As Integer = 3
    Dim s_IPI As Struct_INTERNET_PROXY_INFO
    s_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY
    s_IPI.proxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(strProxy)
    s_IPI.proxyBypass = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("Global")
    Dim intptrStruct As IntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(s_IPI))
    System.Runtime.InteropServices.Marshal.StructureToPtr(s_IPI, intptrStruct, True)
    InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(s_IPI))
End Sub

但这是一个失败,因为发现ip相同,或者在某些情况下是相同的,而4 ip 1不同。

我已经能够用Awesomium实现这一点。你也可以试试。你能更准确地告诉我你是怎么做的吗?我刚刚下载并安装了AwesomiumA webControl,它相当于WebBrowser控件。WebControl具有在实例化时设置的WebSession属性。websession又有一个WebPreferences属性,该属性有一个描述代理设置的ProxyConfig属性。您应该为每个WebControl创建一个新的websession,并在通过proxyconfig设置代理后,为每个控件分配一个不同的webpreferences对象。看到这个:这个:我已经看到了链接,但我是用visual basic编程的,不是用C编程的,总之我尝试了以下代码:Dim WebPreferences1作为Awesomium.Core.WebPreferences WebPreferences1.ProxyConfig=218.108.170.172:82 WebControl1.WebSession=WebCore.CreateWebSessionWebControl1.WebSession.DataPath.ToString,WebPreferences1 WebControl1.Source=新Uri但不起作用C方法和属性与您在vb中调用的方法和属性完全相同。您可以尝试使用designerno代码:从表单1的工具箱中添加websessionprovider。您可以在属性窗格的webpreferences中设置代理。然后将webcontrol添加到表单,并将其websessionprovider设置为您刚才配置的。这应该能说明这个想法