Microsoft WebBrowser control is IE plug-in, all of his functions are like IE, of course, the same settings, the following WebBrowser how to set up the agent, do not use this against the Advertising alliance OH
You can change the proxy with InternetSetOption method from the Wininet.dll, here are a example to set the proxy:
Using System.Runtime.InteropServices;
public struct Struct_internet_proxy_info
{
public int dwaccesstype;
public INTPTR proxy;
Public IntPtr Proxybypass;
};
[DllImport ("Wininet.dll", SetLastError = True)]
private static extern bool InternetSetOption (IntPtr hinternet, int dwoption, IntPtr lpbuffer, int lpdwbufferlength);
private void Refreshiesettings (string strproxy)
{
const int internet_option_proxy = 38;
const int internet_open_type_proxy = 3;
Struct_internet_proxy_info Struct_ipi;
Filling in structure
Struct_ipi.dwaccesstype = Internet_open_type_proxy;
Struct_ipi.proxy = Marshal.stringtohglobalansi (strproxy);
Struct_ipi.proxybypass = Marshal.stringtohglobalansi ("local");
Allocating memory
IntPtr intptrstruct = Marshal.alloccotaskmem (marshal.sizeof (STRUCT_IPI));
Converting structure to INTPTR
Marshal.structuretoptr (Struct_ipi, intptrstruct, true);
BOOL Ireturn = InternetSetOption (IntPtr.Zero, Internet_option_proxy, Intptrstruct, marshal.sizeof (Struct_IPI));
}
private void SomeFunc ()
{
Refreshiesettings ("192.168.1.200:1010");
System.Object nullobject = 0;
String strtemp = String.Empty;
System.Object nullobjstr = strtemp;
Axwebbrowser1.navigate ("http://willstay.tripod.com", ref nullobject, ref NULLOBJSTR, ref NULLOBJSTR, ref NULLOBJSTR);
}
--------------------------------------------------------------------------------------------------------------- ----------------------
Yesterday, the voting opportunity to a new problem, yesterday began the poll began now IP address, each address can only cast 5 votes/day. If every time you change the connection of IE as a proxy server, that also trouble dead, if you use WebClient, that yesterday's 2 hours in vain, the internet a wild collect still really found a way, this good run, built a proxy.txt document, inside put on the proxy server received from the Internet, Then the program read into a ListBox, each time you need to change the IP, just click once, you can also re-vote an address.
Attached Proxy.cs
Using system.runtime.interopservices;//needs to add this reference
public struct Struct_internet_proxy_info
{
public int dwaccesstype;
public INTPTR proxy;
Public IntPtr Proxybypass;
};
[DllImport ("Wininet.dll", SetLastError = True)]
private static extern bool InternetSetOption (IntPtr hinternet, int dwoption, IntPtr lpbuffer, int lpdwbufferlength);
public void Refreshiesettings (string strproxy)
{
const int internet_option_proxy = 38;
const int internet_open_type_proxy = 3;
Struct_internet_proxy_info Struct_ipi;
Filling in structure
Struct_ipi.dwaccesstype = Internet_open_type_proxy;
Struct_ipi.proxy = Marshal.stringtohglobalansi (strproxy);
Struct_ipi.proxybypass = Marshal.stringtohglobalansi ("local");
Allocating memory
IntPtr intptrstruct = Marshal.alloccotaskmem (marshal.sizeof (STRUCT_IPI));
Converting structure to INTPTR
Marshal.structuretoptr (Struct_ipi, intptrstruct, true);
BOOL Ireturn = InternetSetOption (IntPtr.Zero, Internet_option_proxy, Intptrstruct, marshal.sizeof (Struct_IPI));
}
When used, call Refreshiesettings
py.proxy py1 = new proxy();
py1.RefreshIESettings(”221.4.155.51:3128″);
webBrowser1.Navigate(”http://www.hfxsy.cn”, null, null, null);