C# 使用C更改IE IP的问题#
我已经使用此代码一段时间了,现在成功地将代理分配给IE,然后我使用C# 使用C更改IE IP的问题#,c#,visual-studio-2010,proxy,web-scraping,webbrowser-control,C#,Visual Studio 2010,Proxy,Web Scraping,Webbrowser Control,我已经使用此代码一段时间了,现在成功地将代理分配给IE,然后我使用WebBrowser控件导航到页面(由于某些原因,不能使用任何其他方式HttpWebRequest等) 代码是: private void ChangeProxySetting(String proxyHost, Boolean proxyEnabled) { const int INTERNET_OPTION_PROXY = 38; const int INTERNET_OPEN_TYPE_PROXY = 3;
WebBrowser
控件导航到页面(由于某些原因,不能使用任何其他方式HttpWebRequest
等)
代码是:
private void ChangeProxySetting(String proxyHost, Boolean proxyEnabled)
{
const int INTERNET_OPTION_PROXY = 38;
const int INTERNET_OPEN_TYPE_PROXY = 3;
Struct_INTERNET_PROXY_INFO struct_IPI;
struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
struct_IPI.proxy = Marshal.StringToHGlobalAnsi(proxyHost);
struct_IPI.proxyBypass = Marshal.StringToHGlobalAnsi("local");
IntPtr intptrStruct = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI));
Marshal.StructureToPtr(struct_IPI, intptrStruct, true);
bool iReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, Marshal.SizeOf(struct_IPI));
}
但代码突然停止了工作;它绕过了没有错误仍然返回TRUE的情况,但我在IE中没有看到任何代理
在它通过这条线之前,IE有一个代理
有什么建议吗?或者比注册表方式更有效?IE版本过去有效,IE版本不再有效它过去有效,现在不再有效。(最新版本)