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