我使用此功能设置我的webbrowser控件的代理
private void SetProxy(string proxy)
{
INTERNET_PROXY_INFO IPI = new INTERNET_PROXY_INFO();
IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
IPI.lpszProxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(proxy);
IPI.lpszProxyBypass = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("local");
IntPtr intptrStruct = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(IPI));
System.Runtime.InteropServices.Marshal.StructureToPtr(IPI, intptrStruct, true);
InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(IPI));
}
但我之后无法禁用/删除代理,只能将其换成另一个代理。如何完全删除代理。 已经通过注册表尝试。
没有简单的链接作为答案。