The Microsoft webbrowser control is also the IE Plug-in. All its functions are similar to those of IE. Of course, the settings are the same. The following describes how to set up a proxy for webbrowser. Do not use this anti-advertising alliance?
You can change the proxy with internetsetoption method from the wininet. dll, here is 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);
BoolIreturn=Internetsetoption (intptr. Zero, internet_option_proxy, intptrstruct, Marshal. sizeof (struct_ipi ));
}
Private VoidSomefunc ()
{
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 );
}
Certificate -------------------------------------------------------------------------------------------------------------------------------------
A new problem occurs on the polling machine that was created on the last day. The voting started yesterday and now the IP address. Each address can only cast 5 votes/day. If you change the IE connection to a proxy server every time, it will also be annoying, such as the ghost document, which contains the proxy server received from the Internet, and then Program When reading a ListBox, you only need to click it once each time you need to change the IP address, and then you can return an address and vote again.
Add proxy. CS
Using system. runtime. interopservices; // you need 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 ));
}
Call refreshiesettings
Py. Proxy py1 = new proxy ();
Py1.refreshiesettings ("221.4.155.51: 3128 ″);
System. Object nullobject = 0;
String strtemp = string. empty;
System. Object nullobjstr = strtemp;
Webbrowser1.navigate ("http://www.hfxsy.cn", null );