Jos*_*ell 5 c# proxy firewall webbrowser-control windows-10
我的问题是我正在开发一个应用程序实例化多个 webbrowser 对象,每个对象都使用不同的代理浏览互联网。浏览时出现在 Web 浏览器窗口中的是我的查询标题:“已达到最大打开连接数”。阅读文档似乎是我自己的 Windows 防火墙的限制。
如何配置它以允许我增加与 C# 的连接数?
每个webBrowser的代理我都是这样配置的:
[System.Runtime.InteropServices.DllImport("wininet.dll", SetLastError = true)]
internal extern static bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength);
internal struct Struct_INTERNET_PROXY_INFO
{
internal int dwAccessType;
internal IntPtr proxy;
internal IntPtr proxyBypass;
}
internal const int INTERNET_OPTION_PROXY = 38;
internal const int INTERNET_OPEN_TYPE_PROXY = 3;
struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
struct_IPI.proxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(myProxy.Address.Host + ":" + myProxy.Address.Port);
struct_IPI.proxyBypass = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("local");
this.intptrStruct = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI));
System.Runtime.InteropServices.Marshal.StructureToPtr(struct_IPI, intptrStruct, true);
InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))
Run Code Online (Sandbox Code Playgroud)
非常感谢。
| 归档时间: |
|
| 查看次数: |
945 次 |
| 最近记录: |