PageRenderTime 23ms CodeModel.GetById 12ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

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