PageRenderTime 37ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Visual Studio 2008/CSWebBrowserWithProxy/NativeMethods.cs

#
C# | 65 lines | 30 code | 5 blank | 30 comment | 0 complexity | d6ca124b6ea4f9576b18fcd3c6d85b61 MD5 | raw file
  1. /****************************** Module Header ******************************\
  2. Module Name: NativeMethods.cs
  3. Project: CSWebBrowserWithProxy
  4. Copyright (c) Microsoft Corporation.
  5. This class is a simple .NET wrapper of wininet.dll. It contains 4 extern
  6. methods in wininet.dll. They are InternetOpen, InternetCloseHandle,
  7. InternetSetOption and InternetQueryOption.
  8. This source is subject to the Microsoft Public License.
  9. See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
  10. All other rights reserved.
  11. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
  12. EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
  13. WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
  14. \***************************************************************************/
  15. using System;
  16. using System.Runtime.InteropServices;
  17. namespace CSWebBrowserWithProxy
  18. {
  19. internal static class NativeMethods
  20. {
  21. /// <summary>
  22. /// Initialize an application's use of the WinINet functions.
  23. /// See
  24. /// </summary>
  25. [DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)]
  26. internal static extern IntPtr InternetOpen(
  27. string lpszAgent,
  28. int dwAccessType,
  29. string lpszProxyName,
  30. string lpszProxyBypass,
  31. int dwFlags);
  32. /// <summary>
  33. /// Close a single Internet handle.
  34. /// </summary>
  35. [DllImport("wininet.dll", SetLastError = true)]
  36. [return: MarshalAs(UnmanagedType.Bool)]
  37. internal static extern bool InternetCloseHandle(IntPtr hInternet);
  38. /// <summary>
  39. /// Sets an Internet option.
  40. /// </summary>
  41. [DllImport("wininet.dll", CharSet = CharSet.Ansi, SetLastError = true)]
  42. internal static extern bool InternetSetOption(
  43. IntPtr hInternet,
  44. INTERNET_OPTION dwOption,
  45. IntPtr lpBuffer,
  46. int lpdwBufferLength);
  47. /// <summary>
  48. /// Queries an Internet option on the specified handle. The Handle will be always 0.
  49. /// </summary>
  50. [DllImport("wininet.dll", CharSet = CharSet.Ansi, SetLastError = true)]
  51. internal extern static bool InternetQueryOption(
  52. IntPtr hInternet,
  53. INTERNET_OPTION dwOption,
  54. ref INTERNET_PER_CONN_OPTION_LIST OptionList,
  55. ref int lpdwBufferLength);
  56. }
  57. }