我正在尝试使用可以同时运行多个请求(使用Webbrowser控件)但具有不同代理设置的程序在我的服务器上运行特定测试。 我现在使用的是工作,但仅适用于一个webbrowser控件,我正在寻求如何并排运行多个建议。
<Runtime.InteropServices.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
Public Structure Struct_INTERNET_PROXY_INFO
Public dwAccessType As Integer
Public proxy As IntPtr
Public proxyBypass As IntPtr
End Structure
Private Sub RefreshIESettings(ByVal strProxy As String)
Const INTERNET_OPTION_PROXY As Integer = 38
Const 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)
Dim iReturn As Boolean = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))
End Sub
Private Function loadpage()
sInputLine = srFileReader.ReadLine()
Debug.WriteLine("Starting Proxy " & sInputLine)
RefreshIESettings(sInputLine)
Timer1.Enabled = True
Timer1.Interval = My.Settings.timeout * 1000
'set label
Label3.Text = "Attempting: " & sInputLine
Label3.ForeColor = Color.Black
Label3.Visible = True
WebBrowser1.Navigate("http://www.MYSERVER.com")
Return True
End Function
loadpage()正在从DocumentCompleted Event中的计时器循环。
请帮忙,我已经搜索了 - 解决方案。
答案 0 :(得分:0)
无法帮助您使用webbrowser控件本身,但您可以使用具有Proxy属性的HttpWebRequest手动检索远程内容。 http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.proxy.aspx