PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/Visual Studio 2008/CSWebBrowserWithProxy/Readme.txt

#
Plain Text | 79 lines | 54 code | 25 blank | 0 comment | 0 complexity | e3508abed17b21190938906d6b799eea MD5 | raw file
 1================================================================================
 2       Windows APPLICATION: CSWebBrowserWithProxy Overview                        
 3===============================================================================
 4
 5/////////////////////////////////////////////////////////////////////////////
 6Summary:
 7The sample demonstrates how to make WebBrowser use a proxy server.
 8
 9In Internet Explorer 5 and later, Internet options can be set for on a specific 
10connection and process, for example, LAN connection or ADSL connection. Wininet.dll 
11contains 4 extern methods (InternetOpen, InternetCloseHandle, InternetSetOption 
12and InternetQueryOption) to set and retrieve internet settings.
13
14
15
16////////////////////////////////////////////////////////////////////////////////
17Demo:
18
19Step1. Build this project in VS2008. 
20
21Step2. Set the proxy servers in ProxyList.xml.
22       The schema is like  
23	   <ProxyList>
24			<Proxy>
25				<ProxyName>Proxy Name</ProxyName>
26				<Address>Proxy url</Address>
27				<UserName></UserName>
28				<Password></Password>
29			</Proxy> 
30		</ProxyList> 
31		If the proxy server needs credential, UserName and Password should be specified.
32
33Step3. Run CSWebBrowserWithProxy.exe.
34
35Step4. Type http://www.whatsmyip.us/ in the top text box, or any web page that could display
36       your IP.
37
38Step5. Check "No Proxy" and click Go. The browser shows your real IP.
39
40Step6. Check "Proxy Server", choose a Proxy Server in the combo box and click Go. The browser 
41       shows your IP through the Proxy.
42
43
44/////////////////////////////////////////////////////////////////////////////
45Code Logic:
46
471. Wrap 4 extern methods (InternetOpen, InternetCloseHandle, InternetSetOption and 
48   InternetQueryOption) of wininet.dll, design the structure and initialize the constants 
49   used by them.
50
512. Use class WinINet to set proxy, or restore to system internet options.
52       
533. The class WebBrowserControl inherits WebBrowser class and has a feature to set proxy server.  
54   If the Proxy property is changed, it will call methods of the WinINet class to set the 
55   new proxy.
56
574. Initializes the proxy servers in ProxyList.xml when this application starts. 
58
595. Set the proxy of the web browser when the "Go" button was clicked and navigate to the URL.
60
61
62/////////////////////////////////////////////////////////////////////////////
63References:
64
65InternetOpen Function
66http://msdn.microsoft.com/en-us/library/aa385096(VS.85).aspx
67
68InternetCloseHandle Function
69http://msdn.microsoft.com/en-us/library/aa384350(VS.85).aspx
70
71InternetSetOption Function
72http://msdn.microsoft.com/en-us/library/aa385114(VS.85).aspx
73
74InternetQueryOption Function
75http://msdn.microsoft.com/en-us/library/aa385101(VS.85).aspx
76
77Setting and Retrieving Internet Options
78http://msdn.microsoft.com/en-us/library/aa385384(VS.85).aspx
79/////////////////////////////////////////////////////////////////////////////