using System; using System.Linq; using System.Runtime.InteropServices; using Vanara.InteropServices; using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME; namespace Vanara.PInvoke { public static partial class WinINet { /// Uses the default port for FTP servers (port 21). public const ushort INTERNET_DEFAULT_FTP_PORT = 21; /// Uses the default port for Gopher servers (port 70). Note Windows XP and Windows Server 2003 R2 and earlier only. public const ushort INTERNET_DEFAULT_GOPHER_PORT = 70; /// Uses the default port for HTTP servers (port 80). public const ushort INTERNET_DEFAULT_HTTP_PORT = 80; /// Uses the default port for Secure Hypertext Transfer Protocol (HTTPS) servers (port 443). public const ushort INTERNET_DEFAULT_HTTPS_PORT = 443; /// Uses the default port for SOCKS firewall servers (port 1080). public const ushort INTERNET_DEFAULT_SOCKS_PORT = 1080; /// Uses the default port for the service specified by dwService. public const ushort INTERNET_INVALID_PORT_NUMBER = 0; /// Prototype for an application-defined status callback function. /// The handle for which the callback function is called. /// A pointer to a variable that specifies the application-defined context value associated with hInternet. /// A status code that indicates why the callback function is called. /// /// A pointer to additional status information. When the INTERNET_STATUS_STATE_CHANGE flag is set, lpvStatusInformation points to a /// DWORD that contains one or more of the flags. /// /// The size, in bytes, of the data pointed to by lpvStatusInformation. public delegate void INTERNET_STATUS_CALLBACK([In] IntPtr hInternet, [In, Optional] IntPtr dwContext, [In] InternetStatus dwInternetStatus, [In, Optional] IntPtr lpvStatusInformation, [In] uint dwStatusInformationLength); /// Flags used by . [Flags] public enum IDSI_Flags { /// Set if the connection is from the "keep-alive" pool. IDSI_FLAG_KEEP_ALIVE = 0x00000001, /// Set if the HTTP Request is using a secure socket. IDSI_FLAG_SECURE = 0x00000002, /// Set if a proxy is being used to reach the server. IDSI_FLAG_PROXY = 0x00000004, /// Set if a proxy is being used to create a tunnel. IDSI_FLAG_TUNNEL = 0x00000008 } /// Option to be queried or set within structure. public enum INTERNET_PER_CONN_OPTION_ID { /// Sets or retrieves the connection type. INTERNET_PER_CONN_FLAGS = 1, /// Sets or retrieves a string containing the proxy servers. INTERNET_PER_CONN_PROXY_SERVER = 2, /// Sets or retrieves a string containing the URLs that do not use the proxy server. INTERNET_PER_CONN_PROXY_BYPASS = 3, /// Sets or retrieves a string containing the URL to the automatic configuration script. INTERNET_PER_CONN_AUTOCONFIG_URL = 4, /// Sets or retrieves the automatic discovery settings. INTERNET_PER_CONN_AUTODISCOVERY_FLAGS = 5, /// /// Chained autoconfig URL. Used when the primary autoconfig URL points to an INS file that sets a second autoconfig URL for /// proxy information. /// INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL = 6, /// The number of minutes until automatic refresh of autoconfig URL by autodiscovery. INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS = 7, /// Read only option. Returns the time the last known good autoconfig URL was found using autodiscovery. INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME = 8, /// Read only option. Returns the last known good URL found using autodiscovery. INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL = 9, /// Sets or retrieves the connection type. INTERNET_PER_CONN_FLAGS_UI = 10 } /// Options for the function. [Flags] public enum InternetApiFlags : uint { /// Indicates that a Platform for Privacy Protection (P3P) header is to be associated with a cookie. INTERNET_COOKIE_EVALUATE_P3P = 0x80, /// Indicates that a third-party cookie is being set or retrieved. INTERNET_COOKIE_THIRD_PARTY = 0x10, /// /// Makes only asynchronous requests on handles descended from the handle returned from this function. Only the InternetOpen /// function uses this flag. /// INTERNET_FLAG_ASYNC = 0x10000000, /// Allows a lazy cache write. INTERNET_FLAG_CACHE_ASYNC = 0x00000080, /// /// Returns the resource from the cache if the network request for the resource fails due to an ERROR_INTERNET_CONNECTION_RESET /// or ERROR_INTERNET_CANNOT_CONNECT error. This flag is used by HttpOpenRequest. /// INTERNET_FLAG_CACHE_IF_NET_FAIL = 0x00010000, /// Does not add the returned entity to the cache. This is identical to the preferred value, INTERNET_FLAG_NO_CACHE_WRITE. INTERNET_FLAG_DONT_CACHE = 0x04000000, /// /// Attempts to use an existing InternetConnect object if one exists with the same attributes required to make the request. This /// is useful only with FTP operations, since FTP is the only protocol that typically performs multiple operations during the /// same session. WinINet caches a single connection handle for each HINTERNET handle generated by InternetOpen. The /// InternetOpenUrl and InternetConnect functions use this flag for Http and Ftp connections. /// INTERNET_FLAG_EXISTING_CONNECT = 0x20000000, /// Indicates that this is a Forms submission. INTERNET_FLAG_FORMS_SUBMIT = 0x00000040, /// /// Does not make network requests. All entities are returned from the cache. If the requested item is not in the cache, a /// suitable error, such as ERROR_FILE_NOT_FOUND, is returned. Only the InternetOpen function uses this flag. /// INTERNET_FLAG_FROM_CACHE = 0x01000000, /// /// Indicates that the function should use the copy of the resource that is currently in the Internet cache. The expiration date /// and other information about the resource is not checked. If the requested item is not found in the Internet cache, the system /// attempts to locate the resource on the network. This value was introduced in Microsoft Internet Explorer 5 and is associated /// with the Forward and Back button operations of Internet Explorer. /// INTERNET_FLAG_FWD_BACK = 0x00000020, /// /// Forces a reload if there is no Expires time and no LastModified time returned from the server when determining whether to /// reload the item from the network. This flag can be used by FtpFindFirstFile, FtpGetFile, FtpOpenFile, FtpPutFile, /// HttpOpenRequest, and InternetOpenUrl. /// Windows XP and Windows Server 2003 R2 and earlier: Also used by GopherFindFirstFile and GopherOpenFile. /// INTERNET_FLAG_HYPERLINK = 0x00000400, /// /// Disables checking of SSL/PCT-based certificates that are returned from the server against the host name given in the request. /// WinINet uses a simple check against certificates by comparing for matching host names and simple wildcarding rules. This flag /// can be used by HttpOpenRequest and InternetOpenUrl (for HTTP requests). /// INTERNET_FLAG_IGNORE_CERT_CN_INVALID = 0x00001000, /// /// Disables checking of SSL/PCT-based certificates for proper validity dates. This flag can be used by HttpOpenRequest and /// InternetOpenUrl (for HTTP requests). /// INTERNET_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000, /// /// Disables detection of this special type of redirect. When this flag is used, WinINet transparently allows redirects from /// HTTPS to HTTP URLs. This flag can be used by HttpOpenRequest and InternetOpenUrl (for HTTP requests). /// INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP = 0x00008000, /// /// Disables detection of this special type of redirect. When this flag is used, WinINet transparently allow redirects from HTTP /// to HTTPS URLs. This flag can be used by HttpOpenRequest and InternetOpenUrl (for HTTP requests). /// INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS = 0x00004000, /// /// Uses keep-alive semantics, if available, for the connection. This flag is used by HttpOpenRequest and InternetOpenUrl (for /// HTTP requests). This flag is required for Microsoft Network (MSN), NTLM, and other types of authentication. /// INTERNET_FLAG_KEEP_CONNECTION = 0x00400000, /// No longer supported. INTERNET_FLAG_MAKE_PERSISTENT = 0x02000000, /// /// Identical to the preferred value, INTERNET_FLAG_NEED_FILE. Causes a temporary file to be created if the file cannot be /// cached. This flag can be used by FtpFindFirstFile, FtpGetFile, FtpOpenFile, FtpPutFile, HttpOpenRequest, and InternetOpenUrl. /// Windows XP and Windows Server 2003 R2 and earlier: Also used by GopherFindFirstFile and GopherOpenFile. /// INTERNET_FLAG_MUST_CACHE_REQUEST = 0x00000010, /// /// Causes a temporary file to be created if the file cannot be cached. This flag can be used by FtpFindFirstFile, FtpGetFile, /// FtpOpenFile, FtpPutFile, HttpOpenRequest, and InternetOpenUrl. /// Windows XP and Windows Server 2003 R2 and earlier: Also used by GopherFindFirstFile and GopherOpenFile. /// INTERNET_FLAG_NEED_FILE = 0x00000010, /// /// Does not attempt authentication automatically. This flag can be used by HttpOpenRequest and InternetOpenUrl (for HTTP requests). /// INTERNET_FLAG_NO_AUTH = 0x00040000, /// /// Does not automatically handle redirection in HttpSendRequest. This flag can also be used by InternetOpenUrl for HTTP requests. /// INTERNET_FLAG_NO_AUTO_REDIRECT = 0x00200000, /// /// Does not add the returned entity to the cache. This flag is used by , HttpOpenRequest, and InternetOpenUrl. /// Windows XP and Windows Server 2003 R2 and earlier: Also used by GopherFindFirstFile and GopherOpenFile. /// INTERNET_FLAG_NO_CACHE_WRITE = 0x04000000, /// /// Does not automatically add cookie headers to requests, and does not automatically add returned cookies to the cookie /// database. This flag can be used by HttpOpenRequest and InternetOpenUrl (for HTTP requests). /// INTERNET_FLAG_NO_COOKIES = 0x00080000, /// /// Disables the cookie dialog box. This flag can be used by HttpOpenRequest and InternetOpenUrl (HTTP requests only). /// INTERNET_FLAG_NO_UI = 0x00000200, /// /// Identical to INTERNET_FLAG_FROM_CACHE. Does not make network requests. All entities are returned from the cache. If the /// requested item is not in the cache, a suitable error, such as ERROR_FILE_NOT_FOUND, is returned. Only the InternetOpen /// function uses this flag. /// INTERNET_FLAG_OFFLINE = 0x01000000, /// /// Uses passive FTP semantics. Only InternetConnect and InternetOpenUrl use this flag. InternetConnect uses this flag for FTP /// requests, and InternetOpenUrl uses this flag for FTP files and directories. /// INTERNET_FLAG_PASSIVE = 0x08000000, /// /// Forces the request to be resolved by the origin server, even if a cached copy exists on the proxy. The InternetOpenUrl /// function (on HTTP and HTTPS requests only) and HttpOpenRequest function use this flag. /// INTERNET_FLAG_PRAGMA_NOCACHE = 0x00000100, /// /// Returns the data as a WIN32_FIND_DATA structure when retrieving FTP directory information. If this flag is not specified or /// if the call is made through a CERN proxy, InternetOpenUrl returns the HTML version of the directory. Only the InternetOpenUrl /// function uses this flag. /// /// Windows XP and Windows Server 2003 R2 and earlier: Also returns a GOPHER_FIND_DATA structure when retrieving Gopher directory information. /// /// INTERNET_FLAG_RAW_DATA = 0x40000000, /// This flag is currently disabled. INTERNET_FLAG_READ_PREFETCH = 0x00100000, /// /// Forces a download of the requested file, object, or directory listing from the origin server, not from the cache. The /// FtpFindFirstFile, FtpGetFile, FtpOpenFile, FtpPutFile, HttpOpenRequest, and InternetOpenUrl functions use this flag. /// Windows XP and Windows Server 2003 R2 and earlier: Also used by GopherFindFirstFile and GopherOpenFile. /// INTERNET_FLAG_RELOAD = 0x80000000, /// Indicates that the cookie being set is associated with an untrusted site. INTERNET_FLAG_RESTRICTED_ZONE = 0x00020000, /// /// Reloads HTTP resources if the resource has been modified since the last time it was downloaded. All FTP resources are /// reloaded. This flag can be used by FtpFindFirstFile, FtpGetFile, FtpOpenFile, FtpPutFile, HttpOpenRequest, and InternetOpenUrl. /// /// Windows XP and Windows Server 2003 R2 and earlier: Also used by GopherFindFirstFile and GopherOpenFile, and Gopher resources /// are reloaded. /// /// INTERNET_FLAG_RESYNCHRONIZE = 0x00000800, /// /// Uses secure transaction semantics. This translates to using Secure Sockets Layer/Private Communications Technology (SSL/PCT) /// and is only meaningful in HTTP requests. This flag is used by HttpOpenRequest and InternetOpenUrl, but this is redundant if /// https:// appears in the URL.The InternetConnect function uses this flag for HTTP connections; all the request handles created /// under this connection will inherit this flag. /// INTERNET_FLAG_SECURE = 0x00800000, /// Transfers file as ASCII (FTP only). This flag can be used by FtpOpenFile, FtpGetFile, and FtpPutFile. INTERNET_FLAG_TRANSFER_ASCII = 0x00000001, /// Transfers file as binary (FTP only). This flag can be used by FtpOpenFile, FtpGetFile, and FtpPutFile. INTERNET_FLAG_TRANSFER_BINARY = 0x00000002, /// /// Indicates that no callbacks should be made for that API. This is used for the dxContext parameter of the functions that allow /// asynchronous operations. /// INTERNET_NO_CALLBACK = 0x00000000, /// /// Sets an HTTP request object such that it will not logon to origin servers, but will perform automatic logon to HTTP proxy /// servers. This option differs from the Request flag INTERNET_FLAG_NO_AUTH, which prevents authentication to both proxy servers /// and origin servers. Setting this mode will suppress the use of any credential material (either previously provided /// username/password or client SSL certificate) when communicating with an origin server. However, if the request must transit /// via an authenticating proxy, WinINet will still perform automatic authentication to the HTTP proxy per the Intranet Zone /// settings for the user. The default Intranet Zone setting is to permit automatic logon using the user’s default credentials. /// To ensure suppression of all identifying information, the caller should combine INTERNET_OPTION_SUPPRESS_SERVER_AUTH with the /// INTERNET_FLAG_NO_COOKIES request flag. This option may only be set on request objects before they have been sent. Attempts to /// set this option after the request has been sent will return ERROR_INTERNET_INCORRECT_HANDLE_STATE. No buffer is required for /// this option. This is used by InternetSetOption on handles returned by HttpOpenRequest only. Version: Requires Internet /// Explorer 8.0 or later. /// INTERNET_OPTION_SUPPRESS_SERVER_AUTH = 104, /// Forces asynchronous operations. WININET_API_FLAG_ASYNC = 0x00000001, /// Forces synchronous operations. WININET_API_FLAG_SYNC = 0x00000004, /// Forces the API to use the context value, even if it is set to zero. WININET_API_FLAG_USE_CONTEXT = 0x00000008 } /// Values available for the value. [Flags] public enum InternetErrorMask { /// The internet error mask insert cdrom INTERNET_ERROR_MASK_INSERT_CDROM = 0x1, /// The internet error mask combined sec cert INTERNET_ERROR_MASK_COMBINED_SEC_CERT = 0x2, /// The internet error mask need MSN sspi PKG INTERNET_ERROR_MASK_NEED_MSN_SSPI_PKG = 0X4, /// The internet error mask login failure display entity body INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY = 0x8, } /// /// Type of access required for the function. /// public enum InternetOpenType { /// Resolves all host names locally. INTERNET_OPEN_TYPE_DIRECT = 1, /// Retrieves the proxy or direct configuration from the registry. INTERNET_OPEN_TYPE_PRECONFIG = 0, /// /// Retrieves the proxy or direct configuration from the registry and prevents the use of a startup Microsoft JScript or Internet /// Setup (INS) file. /// INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4, /// /// Passes requests to the proxy unless a proxy bypass list is supplied and the name to be resolved bypasses the proxy. In this /// case, the function uses INTERNET_OPEN_TYPE_DIRECT. /// INTERNET_OPEN_TYPE_PROXY = 3 } [Flags] public enum InternetOptionErrorMask { /// Indicates that the client application can handle the ERROR_INTERNET_INSERT_CDROM error code. INTERNET_ERROR_MASK_INSERT_CDROM = 0x1, /// /// Indicates that all certificate errors are to be reported using the same error return, namely ERROR_INTERNET_SEC_CERT_ERRORS. /// If this flag is set, call InternetErrorDlg upon receiving the ERROR_INTERNET_SEC_CERT_ERRORS error, so that the user can /// respond to a familiar dialog describing the problem. Caution Failing to inform the user of this error exposes the user to /// potential spoofing attacks. /// INTERNET_ERROR_MASK_COMBINED_SEC_CERT = 0x2, /// /// Indicates that the client application can handle the ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY error code. /// INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY = 0x8, /// Not implemented. INTERNET_ERROR_MASK_NEED_MSN_SSPI_PKG = 0x4, } /// The following option flags are used with the InternetQueryOption and InternetSetOption functions. [Flags] public enum InternetOptionFlags : uint { /// Not implemented [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_ALTER_IDENTITY = 80, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_ASYNC = 30, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_ASYNC_ID = 15, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_ASYNC_PRIORITY = 16, /// /// Sets or retrieves the Boolean value that determines if the system should check the network for newer content and overwrite /// edited cache entries if a newer version is found. If set to True, the system checks the network for newer content and /// overwrites the edited cache entry with the newer version. The default is False, which indicates that the edited cache entry /// should be used without checking the network. This is used by InternetQueryOption and InternetSetOption. It is valid only in /// Microsoft Internet Explorer 5 and later. /// [CorrespondingType(typeof(bool))] INTERNET_OPTION_BYPASS_EDITED_ENTRY = 64, /// No longer supported. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_CACHE_STREAM_HANDLE = 27, /// /// Retrieves an INTERNET_CACHE_TIMESTAMPS structure that contains the LastModified time and Expires time from the resource /// stored in the Internet cache. This value is used by InternetQueryOption. /// [CorrespondingType(typeof(INTERNET_CACHE_TIMESTAMPS), CorrepsondingAction.Get)] INTERNET_OPTION_CACHE_TIMESTAMPS = 69, /// /// Sets or retrieves the address of the callback function defined for this handle. This option can be used on all HINTERNET /// handles. Used by InternetQueryOption and InternetSetOption. /// [CorrespondingType(typeof(INTERNET_STATUS_CALLBACK))] INTERNET_OPTION_CALLBACK = 1, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_CALLBACK_FILTER = 54, /// /// This flag is not supported by InternetQueryOption. The lpBuffer parameter must be a pointer to a CERT_CONTEXT structure and /// not a pointer to a CERT_CONTEXT pointer. If an application receives ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED, it must call /// InternetErrorDlg or use InternetSetOption to supply a certificate before retrying the request. /// CertDuplicateCertificateContext is then called so that the certificate context passed can be independently released by the application. /// [CorrespondingType(typeof(IntPtr), CorrepsondingAction.Set)] INTERNET_OPTION_CLIENT_CERT_CONTEXT = 84, /// /// For a request where WinInet decompressed the server’s supplied Content-Encoding, retrieves the server-reported Content-Length /// of the response body as a ULONGLONG. Supported in Windows 10, version 1507 and later. /// [CorrespondingType(typeof(ulong), CorrepsondingAction.Get)] INTERNET_OPTION_COMPRESSED_CONTENT_LENGTH = 147, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_CONNECT_BACKOFF = 4, /// /// Sets or retrieves an unsigned long integer value that contains the number of times WinINet attempts to resolve and connect to /// a host. It only attempts once per IP address. For example, if you attempt to connect to a multihome host that has ten IP /// addresses and INTERNET_OPTION_CONNECT_RETRIES is set to seven, WinINet only attempts to resolve and connect to the first /// seven IP addresses. Conversely, given the same set of ten IP addresses, if INTERNET_OPTION_CONNECT_RETRIES is set to 20, /// WinINet attempts each of the ten only once. If a host has only one IP address and the first connection attempt fails, there /// are no further attempts. If a connection attempt still fails after the specified number of attempts, the request is canceled. /// The default value for INTERNET_OPTION_CONNECT_RETRIES is five attempts. This option can be used on any HINTERNET handle, /// including a NULL handle. It is used by InternetQueryOption and InternetSetOption. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_CONNECT_RETRIES = 3, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_CONNECT_TIME = 55, /// /// Sets or retrieves an unsigned long integer value that contains the connected state. This is used by InternetQueryOption and InternetSetOption. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_CONNECTED_STATE = 50, /// /// Sets or retrieves a DWORD_PTR that contains the address of the context value associated with this HINTERNET handle. This /// option can be used on any HINTERNET handle. This is used by InternetQueryOption and InternetSetOption. Previously, this set /// the context value to the address stored in the lpBuffer pointer. This has been corrected so that the value stored in the /// buffer is used and the INTERNET_OPTION_CONTEXT_VALUE flag is assigned a new value. The old value, 10, has been preserved so /// that applications written for the old behavior are still supported. /// [CorrespondingType(typeof(IntPtr))] INTERNET_OPTION_CONTEXT_VALUE = 45, /// Identical to INTERNET_OPTION_RECEIVE_TIMEOUT. This is used by InternetQueryOption and InternetSetOption. [CorrespondingType(typeof(uint))] INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT = 6, /// Identical to INTERNET_OPTION_SEND_TIMEOUT. This is used by InternetQueryOption and InternetSetOption. [CorrespondingType(typeof(uint))] INTERNET_OPTION_CONTROL_SEND_TIMEOUT = 5, /// /// Retrieves a string value that contains the name of the file backing a downloaded entity. This flag is valid after /// InternetOpenUrl, FtpOpenFile, GopherOpenFile, or HttpOpenRequest has completed. This option can only be queried by InternetQueryOption. /// [CorrespondingType(typeof(string), CorrepsondingAction.Get)] INTERNET_OPTION_DATAFILE_NAME = 33, /// /// Sets a string value that contains the extension of the file backing a downloaded entity. This flag should be set before /// calling InternetOpenUrl, FtpOpenFile, GopherOpenFile, or HttpOpenRequest. This option can only be set by InternetSetOption. /// [CorrespondingType(typeof(string), CorrepsondingAction.Set)] INTERNET_OPTION_DATAFILE_EXT = 96, /// /// Causes the system to log off the Digest authentication SSPI package, purging all of the credentials created for the process. /// No buffer is required for this option. It is used by InternetSetOption. /// [CorrespondingType(null, CorrepsondingAction.Set)] INTERNET_OPTION_DIGEST_AUTH_UNLOAD = 76, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_DISABLE_AUTODIAL = 70, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_DISCONNECTED_TIMEOUT = 49, /// /// On a request handle, sets a Boolean controlling whether redirects will be returned from the WinInet cache for a given /// request. The default is FALSE. Supported in Windows 8 and later. /// [CorrespondingType(typeof(bool), CorrepsondingAction.Set)] INTERNET_OPTION_ENABLE_REDIRECT_CACHE_READ = 122, /// /// Gets/sets a BOOL indicating whether non-ASCII characters in the query string should be percent-encoded. The default is FALSE. /// Supported in Windows 8.1 and later. /// [CorrespondingType(typeof(bool))] INTERNET_OPTION_ENCODE_EXTRA = 155, /// /// Flushes entries not in use from the password cache on the hard disk drive. Also resets the cache time used when the /// synchronization mode is once-per-session. No buffer is required for this option. This is used by InternetSetOption. /// [CorrespondingType(null, CorrepsondingAction.Set)] INTERNET_OPTION_END_BROWSER_SESSION = 42, /// Sets an unsigned long integer value that contains the error masks that can be handled by the client application. [CorrespondingType(typeof(InternetErrorMask), CorrepsondingAction.Set)] INTERNET_OPTION_ERROR_MASK = 62, /// /// Sets a PWSTR containing the Enterprise ID (see /// https://msdn.microsoft.com/en-us/library/windows/desktop/mt759320(v=vs.85).aspx) which applies to the request. Supported in /// Windows 10, version 1507 and later. /// [CorrespondingType(typeof(InternetErrorMask), CorrepsondingAction.Set)] INTERNET_OPTION_ENTERPRISE_CONTEXT = 159, /// /// Retrieves an unsigned long integer value that contains a Winsock error code mapped to the ERROR_INTERNET_ error messages last /// returned in this thread context. This option is used on a NULLHINTERNET handle by InternetQueryOption. /// [CorrespondingType(typeof(uint), CorrepsondingAction.Get)] INTERNET_OPTION_EXTENDED_ERROR = 24, /// /// Sets or retrieves a1n unsigned long integer value that contains the amount of time the system should wait for a response to a /// network request before checking the cache for a copy of the resource. If a network request takes longer than the time /// specified and the requested resource is available in the cache, the resource is retrieved from the cache. This is used by /// InternetQueryOption and InternetSetOption. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_FROM_CACHE_TIMEOUT = 63, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Returns a InternetOptionHandleType value. /// [CorrespondingType(typeof(InternetOptionHandleType), CorrepsondingAction.Get)] INTERNET_OPTION_HANDLE_TYPE = 9, /// /// Gets/sets a BOOL indicating whether WinInet should follow HTTP Strict Transport Security (HSTS) directives from servers. If /// enabled, http:// schemed requests to domains which have an HSTS policy cached by WinInet will be redirected to matching /// https:// URLs. The default is FALSE. Supported in Windows 8.1 and later. /// [CorrespondingType(typeof(bool))] INTERNET_OPTION_HSTS = 157, /// /// Enables WinINet to perform decoding for the gzip and deflate encoding schemes. For more information, see Content Encoding. /// [CorrespondingType(typeof(bool), CorrepsondingAction.Set)] INTERNET_OPTION_HTTP_DECODING = 65, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_IDENTITY = 78, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_IDLE_STATE = 51, /// /// Sets or retrieves whether the global offline flag should be ignored for the specified request handle. No buffer is required /// for this option. This is used by InternetQueryOption and InternetSetOption with a request handle. This option is only valid /// in Internet Explorer 5 and later. /// [CorrespondingType(null)] INTERNET_OPTION_IGNORE_OFFLINE = 77, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_KEEP_CONNECTION = 22, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_LISTEN_TIMEOUT = 11, /// /// Sets or retrieves an unsigned long integer value that contains the maximum number of connections allowed per HTTP/1.0 server. /// This is used by InternetQueryOption and InternetSetOption. This option is only valid in Internet Explorer 5 and later. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER = 74, /// /// Sets or retrieves an unsigned long integer value that contains the maximum number of connections allowed per server. This is /// used by InternetQueryOption and InternetSetOption. This option is only valid in Internet Explorer 5 and later. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_MAX_CONNS_PER_SERVER = 73, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_OFFLINE_MODE = 26, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_OFFLINE_SEMANTICS = 52, /// /// Opt-in for weak signatures (e.g. SHA-1) to be treated as insecure. This will instruct WinInet to call CertGetCertificateChain /// using the CERT_CHAIN_OPT_IN_WEAK_SIGNATURE parameter. /// [CorrespondingType(typeof(bool))] INTERNET_OPTION_OPT_IN_WEAK_SIGNATURE = 176, /// Retrieves the parent handle to this handle. This option can be used on any HINTERNET handle by InternetQueryOption. [CorrespondingType(typeof(IntPtr), CorrepsondingAction.Get)] INTERNET_OPTION_PARENT_HANDLE = 21, /// /// Sets or retrieves a string value that contains the password associated with a handle returned by InternetConnect. This is /// used by InternetQueryOption and InternetSetOption. /// [CorrespondingType(typeof(string))] INTERNET_OPTION_PASSWORD = 29, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_POLICY = 48, /// /// Sets or retrieves a string value that contains the password used to access the proxy. This is used by InternetQueryOption and /// InternetSetOption. This option can be set on the handle returned by InternetConnect or HttpOpenRequest. /// [CorrespondingType(typeof(string))] INTERNET_OPTION_PROXY_PASSWORD = 44, /// /// Alerts the current WinInet instance that proxy settings have changed and that they must update with the new settings. To /// alert all available WinInet instances, set the Buffer parameter of InternetSetOption to NULL and BufferLength to 0 when /// passing this option. This option can be set on the handle returned by InternetConnect or HttpOpenRequest. /// [CorrespondingType(null, CorrepsondingAction.Set)] INTERNET_OPTION_PROXY_SETTINGS_CHANGED = 95, /// /// Sets or retrieves a string value that contains the user name used to access the proxy. This is used by InternetQueryOption /// and InternetSetOption. This option can be set on the handle returned by InternetConnect or HttpOpenRequest. /// [CorrespondingType(typeof(string))] INTERNET_OPTION_PROXY_USERNAME = 43, /// /// Sets or retrieves an unsigned long integer value that contains the size of the read buffer. This option can be used on /// HINTERNET handles returned by FtpOpenFile, FtpFindFirstFile, and InternetConnect (FTP session only). This option is used by /// InternetQueryOption and InternetSetOption. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_READ_BUFFER_SIZE = 12, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_RECEIVE_THROUGHPUT = 57, /// /// Causes the proxy data to be reread from the registry for a handle. No buffer is required. This option can be used on the /// HINTERNET handle returned by InternetOpen. It is used by InternetSetOption. /// [CorrespondingType(null, CorrepsondingAction.Set)] INTERNET_OPTION_REFRESH = 37, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_REMOVE_IDENTITY = 79, /// /// Retrieves an unsigned long integer value that contains the special status flags that indicate the status of the download in /// progress. This is used by InternetQueryOption. /// [CorrespondingType(typeof(InternetOptionRequestFlags), CorrepsondingAction.Get)] INTERNET_OPTION_REQUEST_FLAGS = 23, /// /// Sets or retrieves an unsigned long integer value that contains the priority of requests that compete for a connection on an /// HTTP handle. This is used by InternetQueryOption and InternetSetOption. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_REQUEST_PRIORITY = 58, /// /// Starts a new cache session for the process. No buffer is required. This is used by InternetSetOption. This option is reserved /// for internal use only. /// [CorrespondingType(null, CorrepsondingAction.Set)] INTERNET_OPTION_RESET_URLCACHE_SESSION = 60, /// /// Sets or retrieves a string value that contains the secondary cache key. This is used by InternetQueryOption and /// InternetSetOption. This option is reserved for internal use only. /// [CorrespondingType(typeof(string))] INTERNET_OPTION_SECONDARY_CACHE_KEY = 53, /// /// Retrieves the certificate for an SSL/PCT (Secure Sockets Layer/Private Communications Technology) server into a formatted /// string. This is used by InternetQueryOption. /// [CorrespondingType(typeof(string), CorrepsondingAction.Get)] INTERNET_OPTION_SECURITY_CERTIFICATE = 35, /// /// Retrieves the certificate for an SSL/PCT server into the INTERNET_CERTIFICATE_INFO structure. This is used by InternetQueryOption. /// [CorrespondingType(typeof(INTERNET_CERTIFICATE_INFO), CorrepsondingAction.Get)] INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT = 32, /// /// Retrieves an unsigned long integer value that contains the security flags for a handle. This option is used by /// InternetQueryOption. It can be a combination of the following values. /// [CorrespondingType(typeof(InternetOptionSecurityFlags), CorrepsondingAction.Get)] INTERNET_OPTION_SECURITY_FLAGS = 31, /// /// Retrieves an unsigned long integer value that contains the bit size of the encryption key. The larger the number, the greater /// the encryption strength used. This is used by InternetQueryOption. Be aware that the data retrieved this way relates to a /// transaction that has already occurred, whose security level can no longer be changed. /// [CorrespondingType(typeof(uint), CorrepsondingAction.Get)] INTERNET_OPTION_SECURITY_KEY_BITNESS = 36, /// Not implemented. [CorrespondingType(CorrepsondingAction.Exception)] INTERNET_OPTION_SEND_THROUGHPUT = 56, /// /// Notifies the system that the registry settings have been changed so that it verifies the settings on the next call to /// InternetConnect. This is used by InternetSetOption. /// [CorrespondingType(null, CorrepsondingAction.Set)] INTERNET_OPTION_SETTINGS_CHANGED = 39, /// /// A general purpose option that is used to suppress behaviors on a process-wide basis. The lpBuffer parameter of the function /// must be a pointer to a DWORD containing the specific behavior to suppress. This option cannot be queried with /// InternetQueryOption. The permitted values are: /// [CorrespondingType(typeof(InternetOptionSupressBehavior), CorrepsondingAction.Set)] INTERNET_OPTION_SUPPRESS_BEHAVIOR = 81, /// /// Retrieves a string value that contains the full URL of a downloaded resource. If the original URL contained any extra data, /// such as search strings or anchors, or if the call was redirected, the URL returned differs from the original. This option is /// valid on HINTERNET handles returned by InternetOpenUrl, FtpOpenFile, GopherOpenFile, or HttpOpenRequest. It is used by InternetQueryOption. /// [CorrespondingType(typeof(string), CorrepsondingAction.Get)] INTERNET_OPTION_URL = 34, /// /// Sets or retrieves the user agent string on handles supplied by InternetOpen and used in subsequent HttpSendRequest functions, /// as long as it is not overridden by a header added by HttpAddRequestHeaders or HttpSendRequest. This is used by /// InternetQueryOption and InternetSetOption. /// [CorrespondingType(typeof(string))] INTERNET_OPTION_USER_AGENT = 41, /// /// Sets or retrieves a string that contains the user name associated with a handle returned by InternetConnect. This is used by /// InternetQueryOption and InternetSetOption. /// [CorrespondingType(typeof(string))] INTERNET_OPTION_USERNAME = 28, /// /// Retrieves an INTERNET_VERSION_INFO structure that contains the version number of Wininet.dll. This option can be used on a /// NULLHINTERNET handle by InternetQueryOption. /// [CorrespondingType(typeof(INTERNET_VERSION_INFO), CorrepsondingAction.Get)] INTERNET_OPTION_VERSION = 40, /// /// Sets or retrieves an unsigned long integer value that contains the size, in bytes, of the write buffer. This option can be /// used on HINTERNET handles returned by FtpOpenFile and InternetConnect (FTP session only). It is used by InternetQueryOption /// and InternetSetOption. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_WRITE_BUFFER_SIZE = 13, /// /// By default, the host or authority portion of the Unicode URL is encoded according to the IDN specification. Setting this /// option on the request, or connection handle, when IDN is disabled, specifies a code page encoding scheme for the host portion /// of the URL. The lpBuffer parameter in the call to InternetSetOption contains the desired DBCS code page. If no code page is /// specified in lpBuffer, WinINet uses the default system code page (CP_ACP). Note: This option is ignored if IDN is not /// disabled. For more information about how to disable IDN, see the INTERNET_OPTION_IDN option. /// Windows XP with SP2 and Windows Server 2003 with SP1: This flag is not supported. /// Version: Requires Internet Explorer 7.0. /// [CorrespondingType(typeof(uint), CorrepsondingAction.Set)] INTERNET_OPTION_CODEPAGE = 68, /// /// By default, the path portion of the URL is UTF8 encoded. The WinINet API performs escape character (%) encoding on the /// high-bit characters. Setting this option on the request, or connection handle, disables the UTF8 encoding and sets a specific /// code page. The lpBuffer parameter in the call to InternetSetOption contains the desired DBCS codepage for the path. If no /// code page is specified in lpBuffer, WinINet uses the default CP_UTF8. /// Windows XP with SP2 and Windows Server 2003 with SP1: This flag is not supported. /// Version: Requires Internet Explorer 7.0. /// [CorrespondingType(typeof(uint), CorrepsondingAction.Set)] INTERNET_OPTION_CODEPAGE_PATH = 100, /// /// By default, the path portion of the URL is the default system code page (CP_ACP). The escape character (%) conversions are /// not performed on the extra portion. Setting this option on the request, or connection handle disables the CP_ACP encoding. /// The lpBuffer parameter in the call to InternetSetOption contains the desired DBCS codepage for the extra portion of the URL. /// If no code page is specified in lpBuffer, WinINet uses the default system code page (CP_ACP). /// Windows XP with SP2 and Windows Server 2003 with SP1: This flag is not supported. /// Version: Requires Internet Explorer 7.0. /// [CorrespondingType(typeof(uint), CorrepsondingAction.Set)] INTERNET_OPTION_CODEPAGE_EXTRA = 101, /// /// Sets or retrieves an unsigned long integer value that contains the time-out value, in milliseconds, to use for Internet /// connection requests. Setting this option to infinite (0xFFFFFFFF) will disable this timer. If a connection request takes /// longer than this time-out value, the request is canceled. When attempting to connect to multiple IP addresses for a single /// host (a multihome host), the timeout limit is cumulative for all of the IP addresses. This option can be used on any /// HINTERNET handle, including a NULL handle. It is used by InternetQueryOption and InternetSetOption. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_CONNECT_TIMEOUT = 2, /// /// Sets or retrieves an unsigned long integer value that contains the time-out value, in milliseconds, to receive a response to /// a request for the data channel of an FTP transaction. If the response takes longer than this time-out value, the request is /// canceled. This option can be used on any HINTERNET handle, including a NULL handle. It is used by InternetQueryOption and /// InternetSetOption. This flag has no impact on HTTP functionality. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_DATA_RECEIVE_TIMEOUT = 8, /// /// Sets or retrieves an unsigned long integer value, in milliseconds, that contains the time-out value to send a request for the /// data channel of an FTP transaction. If the send takes longer than this time-out value, the send is canceled. This option can /// be used on any HINTERNET handle, including a NULL handle. It is used by InternetQueryOption and InternetSetOption. This flag /// has no impact on HTTP functionality. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_DATA_SEND_TIMEOUT = 7, /// /// Retrieves an INTERNET_DIAGNOSTIC_SOCKET_INFO structure that contains data about a specified HTTP Request. This flag is used /// by InternetQueryOption. Windows 7: This option is no longer supported. /// [CorrespondingType(typeof(INTERNET_DIAGNOSTIC_SOCKET_INFO), CorrepsondingAction.Get)] INTERNET_OPTION_DIAGNOSTIC_SOCKET_INFO = 67, /// /// Sets a DWORD bitmask of acceptable advanced HTTP versions. May be set on any handle type. Possible values are: /// HTTP_PROTOCOL_FLAG_HTTP2 (0x2). Supported on Windows 10, version 1507 and later. Legacy versions of HTTP (1.1 and prior) /// cannot be disabled using this option. The default is 0x0. Supported in Windows 10, version 1507 and later. /// [CorrespondingType(typeof(uint), CorrepsondingAction.Set)] INTERNET_OPTION_ENABLE_HTTP_PROTOCOL = 148, /// /// Gets a DWORD indicating which advanced HTTP version was used on a given request. Possible values are: /// HTTP_PROTOCOL_FLAG_HTTP2 (0x2). Supported on Windows 10, version 1507 and later. 0x0 indicates HTTP/1.1 or earlier; see /// INTERNET_OPTION_HTTP_VERSION if more precision is needed about which legacy version was used. Supported on Windows 10, /// version 1507 and later. /// [CorrespondingType(typeof(uint), CorrepsondingAction.Get)] INTERNET_OPTION_HTTP_PROTOCOL_USED = 149, /// /// Sets or retrieves an HTTP_VERSION_INFO structure that contains the supported HTTP version. This must be used on a NULL /// handle. This is used by InternetQueryOption and InternetSetOption. On Windows 7, Windows Server 2008 R2, and later, the value /// of the dwMinorVersion member in the HTTP_VERSION_INFO structure is overridden by Internet Explorer settings. EnableHttp1_1 is /// a registry value under HKLM\Software\Microsoft\InternetExplorer\AdvacnedOptions\HTTP\GENABLE controlled by Internet Options /// set in Internet Explorer for the system. The EnableHttp1_1 value defaults to 1. The HTTP_VERSION_INFO structure is ignored /// for any HTTP version less than 1.1 if EnableHttp1_1 is set to 1. /// [CorrespondingType(typeof(HTTP_VERSION_INFO))] INTERNET_OPTION_HTTP_VERSION = 59, /// /// By default, the host or authority portion of the URL is encoded according to the IDN specification for both direct and proxy /// connections. This option can be used on the request, or connection handle to enable or disable IDN. When IDN is disabled, /// WinINet uses the system codepage to encode the host or authority portion of the URL. To disable IDN host conversion, set the /// lpBuffer parameter in the call to InternetSetOption to zero. To enable IDN conversion on only the direct connection, specify /// INTERNET_FLAG_IDN_DIRECT in the lpBuffer parameter in the call to InternetSetOption. To enable IDN conversion on only the /// proxy connection, specify INTERNET_FLAG_IDN_PROXY in the lpBuffer parameter in the call to InternetSetOption. Windows XP with /// SP2 and Windows Server 2003 with SP1: This flag is not supported. /// Version: Requires Internet Explorer 7.0. /// [CorrespondingType(typeof(InternetOptionIDNFlags), CorrepsondingAction.Set)] INTERNET_OPTION_IDN = 102, /// /// Sets or retrieves an unsigned long integer value that contains the maximum number of connections allowed per CERN proxy. When /// this option is set or retrieved, the hInternet parameter must set to a null handle value. A null handle value indicates that /// the option should be set or queried for the current process. When calling InternetSetOption with this option, all existing /// proxy objects will receive the new value. This value is limited to a range of 2 to 128, inclusive. Version: Requires /// Internet Explorer 8.0. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_MAX_CONNS_PER_PROXY = 103, /// /// Sets or retrieves an INTERNET_PER_CONN_OPTION_LIST structure that specifies a list of options for a particular connection. /// This is used by InternetQueryOption and InternetSetOption. This option is only valid in Internet Explorer 5 and later. Note /// INTERNET_OPTION_PER_CONNECTION_OPTION causes the settings to be changed on a system-wide basis when a NULL handle is used in /// the call to InternetSetOption. To refresh the global proxy settings, you must call InternetSetOption with the /// INTERNET_OPTION_REFRESH option flag. Note To change proxy information for the entire process without affecting the global /// settings in Internet Explorer 5 and later, use this option on the handle that is returned from InternetOpen. The following /// code example changes the proxy for the whole process even though the HINTERNET handle is closed and is not used by any /// requests. For more information and code examples, see KB article 226473. /// [CorrespondingType(typeof(INTERNET_PER_CONN_OPTION_LIST))] INTERNET_OPTION_PER_CONNECTION_OPTION = 75, /// /// Sets or retrieves an INTERNET_PROXY_INFO structure that contains the proxy data for an existing InternetOpen handle when the /// HINTERNET handle is not NULL. If the HINTERNET handle is NULL, the function sets or queries the global proxy data. This /// option can be used on the handle returned by InternetOpen. It is used by InternetQueryOption and InternetSetOption. Note It /// is recommended that INTERNET_OPTION_PER_CONNECTION_OPTION be used instead of INTERNET_OPTION_PROXY. For more information, see /// KB article 226473. /// [CorrespondingType(typeof(INTERNET_PROXY_INFO))] INTERNET_OPTION_PROXY = 38, /// /// Sets or retrieves an unsigned long integer value that contains the time-out value, in milliseconds, to receive a response to /// a request. If the response takes longer than this time-out value, the request is canceled. This option can be used on any /// HINTERNET handle, including a NULL handle. It is used by InternetQueryOption and InternetSetOption. This option is not /// intended to represent a fine-grained, immediate timeout. You can expect the timeout to occur up to six seconds after the set /// timeout value. When used in reference to an FTP transaction, this option refers to the control channel. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_RECEIVE_TIMEOUT = 6, /// /// The bit size used in the encryption is unknown. This is only returned in a call to InternetQueryOption. Be aware that the /// data retrieved this way relates to a transaction that has occurred, whose security level can no longer be changed. /// [CorrespondingType(typeof(uint), CorrepsondingAction.Get)] SECURITY_FLAG_UNKNOWNBIT = 0x80000000, /// /// Sets or retrieves an unsigned long integer value, in milliseconds, that contains the time-out value to send a request. If the /// send takes longer than this time-out value, the send is canceled. This option can be used on any HINTERNET handle, including /// a NULL handle. It is used by InternetQueryOption and InternetSetOption. When used in reference to an FTP transaction, this /// option refers to the control channel. /// [CorrespondingType(typeof(uint))] INTERNET_OPTION_SEND_TIMEOUT = 5, /// /// Retrieves the server’s certificate-chain context as a duplicated PCCERT_CHAIN_CONTEXT. You may pass this duplicated context /// to any Crypto API function which takes a PCCERT_CHAIN_CONTEXT. You must call CertFreeCertificateChain on the returned /// PCCERT_CHAIN_CONTEXT when you are done with the certificate-chain context. Version: Requires Internet Explorer 8.0. /// [CorrespondingType(typeof(IntPtr), CorrepsondingAction.Get)] INTERNET_OPTION_SERVER_CERT_CHAIN_CONTEXT = 105, /// /// Sets an HTTP request object such that it will not logon to origin servers, but will perform automatic logon to HTTP proxy /// servers. This option differs from the Request flag INTERNET_FLAG_NO_AUTH, which prevents authentication to both proxy servers /// and origin servers. Setting this mode will suppress the use of any credential material (either previously provided /// username/password or client SSL certificate) when communicating with an origin server. However, if the request must transit /// via an authenticating proxy, WinINet will still perform automatic authentication to the HTTP proxy per the Intranet Zone /// settings for the user. The default Intranet Zone setting is to permit automatic logon using the user’s default credentials. /// To ensure suppression of all identifying information, the caller should combine INTERNET_OPTION_SUPPRESS_SERVER_AUTH with the /// INTERNET_FLAG_NO_COOKIES request flag. This option may only be set on request objects before they have been sent. Attempts to /// set this option after the request has been sent will return ERROR_INTERNET_INCORRECT_HANDLE_STATE. No buffer is required for /// this option. This is used by InternetSetOption on handles returned by HttpOpenRequest only. /// Version: Requires Internet Explorer 8.0 or later. /// [CorrespondingType(null, CorrepsondingAction.Set)] INTERNET_OPTION_SUPPRESS_SERVER_AUTH = 104, } public enum InternetOptionHandleType { /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_CONNECT_FTP = 2, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_CONNECT_GOPHER = 3, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_CONNECT_HTTP = 4, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_FILE_REQUEST = 14, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_FTP_FILE = 7, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_FTP_FILE_HTML = 8, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_FTP_FIND = 5, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_FTP_FIND_HTML = 6, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_GOPHER_FILE = 11, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_GOPHER_FILE_HTML = 12, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_GOPHER_FIND = 9, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_GOPHER_FIND_HTML = 10, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_HTTP_REQUEST = 13, /// /// Retrieves an unsigned long integer value that contains the type of the HINTERNET handles passed in. This is used by /// InternetQueryOption on any HINTERNET handle. Possible return values include the following. /// INTERNET_HANDLE_TYPE_INTERNET = 1, } [Flags] public enum InternetOptionIDNFlags { /// IDN enabled for direct connections INTERNET_FLAG_IDN_DIRECT = 0x00000001, /// IDN enabled for proxy INTERNET_FLAG_IDN_PROXY = 0x00000002 } [Flags] public enum InternetOptionRequestFlags { /// Not implemented. INTERNET_REQFLAG_ASYNC = 0x00000002, /// Internet request cannot be cached (an HTTPS request, for example). INTERNET_REQFLAG_CACHE_WRITE_DISABLED = 0x00000040, /// Response came from the cache. INTERNET_REQFLAG_FROM_CACHE = 0x00000001, /// Internet request timed out. INTERNET_REQFLAG_NET_TIMEOUT = 0x00000080, /// Original response contained no headers. INTERNET_REQFLAG_NO_HEADERS = 0x00000008, /// Not implemented. INTERNET_REQFLAG_PASSIVE = 0x00000010, /// Request was made through a proxy. INTERNET_REQFLAG_VIA_PROXY = 0x00000004, } [Flags] public enum InternetOptionSecurityFlags { /// Identical to the preferred value SECURITY_FLAG_STRENGTH_STRONG. This is only returned in a call to InternetQueryOption. SECURITY_FLAG_128BIT = 0x20000000, /// Identical to the preferred value SECURITY_FLAG_STRENGTH_WEAK. This is only returned in a call to InternetQueryOption. SECURITY_FLAG_40BIT = 0x10000000, /// Identical to the preferred value SECURITY_FLAG_STRENGTH_MEDIUM. This is only returned in a call to InternetQueryOption. SECURITY_FLAG_56BIT = 0x40000000, /// Indicates Fortezza has been used to provide secrecy, authentication, and/or integrity for the specified connection. SECURITY_FLAG_FORTEZZA = 0x08000000, /// Not implemented. SECURITY_FLAG_IETFSSL4 = 0x00000020, /// Ignores the ERROR_INTERNET_SEC_CERT_CN_INVALID error message. SECURITY_FLAG_IGNORE_CERT_CN_INVALID = 0x00001000, /// Ignores the ERROR_INTERNET_SEC_CERT_DATE_INVALID error message. SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000, /// Ignores the ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR error message. SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTP = 0x00008000, /// Ignores the ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR error message. SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTPS = 0x00004000, /// Ignores certificate revocation problems. SECURITY_FLAG_IGNORE_REVOCATION = 0x00000080, /// Ignores unknown certificate authority problems. SECURITY_FLAG_IGNORE_UNKNOWN_CA = 0x00000100, /// Ignores weak certificate signature problems. SECURITY_FLAG_IGNORE_WEAK_SIGNATURE = 0x00010000, /// Ignores incorrect usage problems. SECURITY_FLAG_IGNORE_WRONG_USAGE = 0x00000200, /// Identical to the value SECURITY_FLAG_STRENGTH_WEAK. This is only returned in a call to InternetQueryOption. SECURITY_FLAG_NORMALBITNESS = 0x10000000, /// Not implemented. SECURITY_FLAG_PCT = 0x00000008, /// Not implemented. SECURITY_FLAG_PCT4 = 0x00000010, /// Uses secure transfers. This is only returned in a call to InternetQueryOption. SECURITY_FLAG_SECURE = 0x00000001, /// Not implemented. SECURITY_FLAG_SSL = 0x00000002, /// Not implemented. SECURITY_FLAG_SSL3 = 0x00000004, /// Uses medium (56-bit) encryption. This is only returned in a call to InternetQueryOption. SECURITY_FLAG_STRENGTH_MEDIUM = 0x40000000, /// Uses strong (128-bit) encryption. This is only returned in a call to InternetQueryOption. SECURITY_FLAG_STRENGTH_STRONG = 0x20000000, /// Uses weak (40-bit) encryption. This is only returned in a call to InternetQueryOption. SECURITY_FLAG_STRENGTH_WEAK = 0x10000000, } public enum InternetOptionSupressBehavior { /// /// Disables all suppressions, re-enabling default and configured behavior. This option is the equivalent of setting /// INTERNET_SUPPRESS_COOKIE_POLICY_RESET and INTERNET_SUPPRESS_COOKIE_PERSIST_RESET individually. Version: Requires /// Internet Explorer 6.0 or later. /// INTERNET_SUPPRESS_RESET_ALL = 0, /// /// Ignores any configured cookie policies and allows cookies to be set. Version: Requires Internet Explorer 6.0 or later. /// INTERNET_SUPPRESS_COOKIE_POLICY = 1, /// /// Disables the INTERNET_SUPPRESS_COOKIE_POLICY suppression, permitting the evaluation of cookies according to the configured /// cookie policy. Version: Requires Internet Explorer 6.0 or later. /// INTERNET_SUPPRESS_COOKIE_POLICY_RESET = 2, /// /// Suppresses the persistence of cookies, even if the server has specified them as persistent. Version: Requires Internet /// Explorer 8.0 or later. /// INTERNET_SUPPRESS_COOKIE_PERSIST = 3, /// /// Disables the INTERNET_SUPPRESS_COOKIE_PERSIST suppression, re-enabling the persistence of cookies. Any previously suppressed /// cookies will not become persistent. Version: Requires Internet Explorer 8.0 or later. /// INTERNET_SUPPRESS_COOKIE_PERSIST_RESET = 4 } /// Type of service to access in . public enum InternetService { /// FTP service. INTERNET_SERVICE_FTP = 1, /// Gopher service. Windows XP and Windows Server 2003 R2 and earlier only. INTERNET_SERVICE_GOPHER = 2, /// HTTP service. INTERNET_SERVICE_HTTP = 3 } /// Values passed using the delegate. [Flags] public enum InternetState { /// Connected state. Mutually exclusive with disconnected state. INTERNET_STATE_CONNECTED = 1, /// Disconnected state. No network connection could be established. INTERNET_STATE_DISCONNECTED = 2, /// Disconnected by user request. INTERNET_STATE_DISCONNECTED_BY_USER = 0x10, /// No network requests are being made by Windows Internet. INTERNET_STATE_IDLE = 0x100, /// Network requests are being made by Windows Internet. INTERNET_STATE_BUSY = 0x200, } /// Values passed using the delegate. public enum InternetStatus { /// Closing the connection to the server. The lpvStatusInformation parameter is NULL. INTERNET_STATUS_CLOSING_CONNECTION = 50, /// Successfully connected to the socket address (SOCKADDR) pointed to by lpvStatusInformation. INTERNET_STATUS_CONNECTED_TO_SERVER = 21, /// Connecting to the socket address (SOCKADDR) pointed to by lpvStatusInformation. INTERNET_STATUS_CONNECTING_TO_SERVER = 20, /// Successfully closed the connection to the server. The lpvStatusInformation parameter is NULL. INTERNET_STATUS_CONNECTION_CLOSED = 51, /// /// Retrieving content from the cache. Contains data about past cookie events for the URL such as if cookies were accepted, /// rejected, downgraded, or leashed. The lpvStatusInformation parameter is a pointer to an InternetCookieHistory structure. /// INTERNET_STATUS_COOKIE_HISTORY = 327, /// /// Indicates the number of cookies that were accepted, rejected, downgraded (changed from persistent to session cookies), or /// leashed (will be sent out only in 1st party context). The lpvStatusInformation parameter is a DWORD with the number of /// cookies received. /// INTERNET_STATUS_COOKIE_RECEIVED = 321, /// /// Indicates the number of cookies that were either sent or suppressed, when a request is sent. The lpvStatusInformation /// parameter is a DWORD with the number of cookies sent or suppressed. /// INTERNET_STATUS_COOKIE_SENT = 320, /// Not implemented. INTERNET_STATUS_CTL_RESPONSE_RECEIVED = 42, /// Notifies the client application that a proxy has been detected. INTERNET_STATUS_DETECTING_PROXY = 80, /// /// This handle value has been terminated. pvStatusInformation contains the address of the handle being closed. The /// lpvStatusInformation parameter contains the address of the handle being closed. /// INTERNET_STATUS_HANDLE_CLOSING = 70, /// /// Used by InternetConnect to indicate it has created the new handle. This lets the application call InternetCloseHandle from /// another thread, if the connect is taking too long. The lpvStatusInformation parameter contains the address of an HINTERNET handle. /// INTERNET_STATUS_HANDLE_CREATED = 60, /// Received an intermediate (100 level) status code message from the server. INTERNET_STATUS_INTERMEDIATE_RESPONSE = 120, /// /// Successfully found the IP address of the name contained in lpvStatusInformation. The lpvStatusInformation parameter points to /// a PCTSTR containing the host name. /// INTERNET_STATUS_NAME_RESOLVED = 11, /// The response has a P3P header in it. INTERNET_STATUS_P3P_HEADER = 325, /// Not implemented. INTERNET_STATUS_P3P_POLICYREF = 326, /// Not implemented. INTERNET_STATUS_PREFETCH = 43, /// Not implemented. INTERNET_STATUS_PRIVACY_IMPACTED = 324, /// Waiting for the server to respond to a request. The lpvStatusInformation parameter is NULL. INTERNET_STATUS_RECEIVING_RESPONSE = 40, /// /// An HTTP request is about to automatically redirect the request. The lpvStatusInformation parameter points to the new URL. At /// this point, the application can read any data returned by the server with the redirect response and can query the response /// headers. It can also cancel the operation by closing the handle. This callback is not made if the original request specified INTERNET_FLAG_NO_AUTO_REDIRECT. /// INTERNET_STATUS_REDIRECT = 110, /// /// An asynchronous operation has been completed. The lpvStatusInformation parameter contains the address of an /// INTERNET_ASYNC_RESULT structure. /// INTERNET_STATUS_REQUEST_COMPLETE = 100, /// /// Successfully sent the information request to the server. The lpvStatusInformation parameter points to a DWORD value that /// contains the number of bytes sent. /// INTERNET_STATUS_REQUEST_SENT = 31, /// /// Looking up the IP address of the name contained in lpvStatusInformation. The lpvStatusInformation parameter points to a /// PCTSTR containing the host name. /// INTERNET_STATUS_RESOLVING_NAME = 10, /// Successfully received a response from the server. INTERNET_STATUS_RESPONSE_RECEIVED = 41, /// Sending the information request to the server. The lpvStatusInformation parameter is NULL. INTERNET_STATUS_SENDING_REQUEST = 30, /// /// Moved between a secure (HTTPS) and a nonsecure (HTTP) site. The user must be informed of this change; otherwise, the user is /// at risk of disclosing sensitive information involuntarily. When this flag is set, the lpvStatusInformation parameter points /// to a status DWORD that contains additional flags. /// INTERNET_STATUS_STATE_CHANGE = 200, /// The request requires user input to be completed. INTERNET_STATUS_USER_INPUT_REQUIRED = 140, } /// Closes a single Internet handle. /// Handle to be closed. /// Returns TRUE if the handle is successfully closed, or FALSE otherwise. To get extended error information, call GetLastError. [DllImport(Lib.WinInet, ExactSpelling = true, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool InternetCloseHandle(IntPtr hInternet); /// Opens an File Transfer Protocol (FTP) or HTTP session for a given site. /// Handle returned by a previous call to InternetOpen. /// /// A string that specifies the host name of an Internet server. Alternately, the string can contain the IP number of the site, in /// ASCII dotted-decimal format (for example, 11.0.1.45). /// /// /// Transmission Control Protocol/Internet Protocol (TCP/IP) port on the server. These flags set only the port that is used. The /// service is set by the value of dwService. /// /// /// A string that specifies the name of the user to log on. If this parameter is NULL, the function uses an appropriate default. For /// the FTP protocol, the default is "anonymous". /// /// /// A string that contains the password to use to log on. If both lpszPassword and lpszUsername are NULL, the function uses the /// default "anonymous" password. In the case of FTP, the default password is the user's email name. If lpszPassword is NULL, but /// lpszUsername is not NULL, the function uses a blank password. /// /// Type of service to access. /// /// Options specific to the service used. If dwService is INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE causes the application to use /// passive FTP semantics. /// /// /// Pointer to a variable that contains an application-defined value that is used to identify the application context for the /// returned handle in callbacks. /// /// /// Returns a valid handle to the session if the connection is successful, or NULL otherwise. To retrieve extended error information, /// call GetLastError. An application can also use InternetGetLastResponseInfo to determine why access to the service was denied. /// [DllImport(Lib.WinInet, CharSet = CharSet.Auto, SetLastError = true)] public static extern SafeInternetConnectHandle InternetConnect(SafeInternetHandle hInternet, string lpszServerName, ushort nServerPort, string lpszUsername, string lpszPassword, InternetService dwService, InternetApiFlags dwFlags, IntPtr dwContext); /// Initializes an application's use of the WinINet functions /// /// A string that specifies the name of the application or entity calling the WinINet functions. This name is used as the user agent /// in the HTTP protocol. /// /// Type of access required. /// /// A string that specifies the name of the proxy server(s) to use when proxy access is specified by setting dwAccessType to /// INTERNET_OPEN_TYPE_PROXY. Do not use an empty string, because InternetOpen will use it as the proxy name. The WinINet functions /// recognize only CERN type proxies (HTTP only) and the TIS FTP gateway (FTP only). If Microsoft Internet Explorer is installed, /// these functions also support SOCKS proxies. FTP requests can be made through a CERN type proxy either by changing them to an HTTP /// request or by using InternetOpenUrl. If dwAccessType is not set to INTERNET_OPEN_TYPE_PROXY, this parameter is ignored and should /// be NULL. For more information about listing proxy servers, see the Listing Proxy Servers section of Enabling Internet Functionality. /// /// /// A string that specifies an optional list of host names or IP addresses, or both, that should not be routed through the proxy when /// dwAccessType is set to INTERNET_OPEN_TYPE_PROXY. The list can contain wildcards. Do not use an empty string, because InternetOpen /// will use it as the proxy bypass list. If this parameter specifies the "<local>" macro, the function bypasses the proxy for /// any host name that does not contain a period. /// /// By default, WinINet will bypass the proxy for requests that use the host names "localhost", "loopback", "127.0.0.1", or "[::1]". /// This behavior exists because a remote proxy server typically will not resolve these addresses properly. /// /// Internet Explorer 9: You can remove the local computer from the proxy bypass list using the "<-loopback>" macro. /// If dwAccessType is not set to INTERNET_OPEN_TYPE_PROXY, this parameter is ignored and should be NULL. /// /// Options. /// /// Returns a valid handle that the application passes to subsequent WinINet functions. If InternetOpen fails, it returns NULL. To /// retrieve a specific error message, call GetLastError. /// [DllImport(Lib.WinInet, CharSet = CharSet.Auto, SetLastError = true)] public static extern SafeInternetHandle InternetOpen(string lpszAgent, InternetOpenType dwAccessType, string lpszProxyName, string lpszProxyBypass, InternetApiFlags dwFlags); /// Queries an Internet option on the specified handle. /// Handle on which to query information. /// Internet option to be queried. This can be one of the Option Flags values. /// /// Pointer to a buffer that receives the option setting. Strings returned by InternetQueryOption are globally allocated, so the /// calling application must free them when it is finished using them. /// /// /// Pointer to a variable that contains the size of lpBuffer, in bytes. When InternetQueryOption returns, lpdwBufferLength specifies /// the size of the data placed into lpBuffer. If GetLastError returns ERROR_INSUFFICIENT_BUFFER, this parameter points to the number /// of bytes required to hold the requested information. /// /// Returns TRUE if successful, or FALSE otherwise. To get a specific error message, call GetLastError. [DllImport(Lib.WinInet, CharSet = CharSet.Auto, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool InternetQueryOption(SafeInternetHandle hInternet, InternetOptionFlags dwOption, IntPtr optionsList, ref int bufferLength); /// Queries an Internet option on the specified handle. /// Handle on which to query information. /// Internet option to be queried. This can be one of the Option Flags values. /// /// A instance with sufficient memory needed to hold the response. This should be cast to the type required. /// public static SafeCoTaskMemHandle InternetQueryOption(this SafeInternetHandle hInternet, InternetOptionFlags option) { var sz = 0; InternetQueryOption(hInternet, option, IntPtr.Zero, ref sz); var err = Win32Error.GetLastError(); if (err != Win32Error.ERROR_INSUFFICIENT_BUFFER) err.ThrowIfFailed(); var hMem = new SafeCoTaskMemHandle(sz); var res = InternetQueryOption(hInternet, option, (IntPtr)hMem, ref sz); if (!res) Win32Error.ThrowLastError(); return hMem; } /// Queries an Internet option on the specified handle. /// The expected type returned by the option. /// Handle on which to query information. /// Internet option to be queried. This can be one of the Option Flags values. /// The option setting. public static T InternetQueryOption(this SafeInternetHandle hInternet, InternetOptionFlags option) { if (!CorrespondingTypeAttribute.CanGet(option, typeof(T))) throw new ArgumentException($"{option} cannot be used to get values of type {typeof(T)}."); var hMem = InternetQueryOption(hInternet, option); return typeof(T) == typeof(string) ? (T)(object)hMem.ToString(-1) : (typeof(T) == typeof(bool) ? (T)(object)Convert.ToBoolean(hMem.ToStructure()) : hMem.ToStructure()); } /// Sets an Internet option. /// Handle on which to set information. /// Internet option to be set. This can be one of the Option Flags values. /// Pointer to a buffer that contains the option setting. /// /// Size of the lpBuffer buffer. If lpBuffer contains a string, the size is in TCHARs. If lpBuffer contains anything other than a /// string, the size is in bytes. /// /// Returns TRUE if successful, or FALSE otherwise. To get a specific error message, call GetLastError. [DllImport(Lib.WinInet, CharSet = CharSet.Auto, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool InternetSetOption(SafeInternetHandle hInternet, InternetOptionFlags dwOption, IntPtr lpBuffer, int lpdwBufferLength); /// Sets an Internet option /// Handle on which to set information. /// Internet option to be set. This can be one of the Option Flags values. public static void InternetSetOption(this SafeInternetHandle hInternet, InternetOptionFlags option) { if (CorrespondingTypeAttribute.GetCorrespondingTypes(option).FirstOrDefault() != null) throw new ArgumentException($"{option} cannot be used to set options that do not require a value."); var res = InternetSetOption(hInternet, option, IntPtr.Zero, 0); if (!res) Win32Error.ThrowLastError(); } /// Sets an Internet option /// The type expected by the option. /// Handle on which to set information. /// Internet option to be set. This can be one of the Option Flags values. /// The option setting value. public static void InternetSetOption(this SafeInternetHandle hInternet, InternetOptionFlags option, T value) { if (!CorrespondingTypeAttribute.CanSet(option, typeof(T))) throw new ArgumentException($"{option} cannot be used to set values of type {typeof(T)}."); var hMem = typeof(T) == typeof(string) ? new SafeCoTaskMemHandle(value?.ToString()) : (typeof(T) == typeof(bool) ? SafeCoTaskMemHandle.CreateFromStructure(Convert.ToUInt32(value)) : SafeCoTaskMemHandle.CreateFromStructure(value)); var res = InternetSetOption(hInternet, option, (IntPtr)hMem, typeof(T) == typeof(string) ? value?.ToString().Length + 1 ?? 0 : hMem.Size); if (!res) Win32Error.ThrowLastError(); } /// /// The InternetSetStatusCallback function sets up a callback function that WinINet functions can call as progress is made during an operation. /// /// The handle for which the callback is set. /// /// A pointer to the callback function to call when progress is made, or NULL to remove the existing callback function. For more /// information about the callback function, see InternetStatusCallback. /// /// /// Returns the previously defined status callback function if successful, NULL if there was no previously defined status callback /// function, or INTERNET_INVALID_STATUS_CALLBACK if the callback function is not valid. /// [DllImport(Lib.WinInet, ExactSpelling = true, SetLastError = true)] public static extern IntPtr InternetSetStatusCallback(SafeInternetHandle hInternet, INTERNET_STATUS_CALLBACK lpfnInternetCallback); [DllImport("inetcpl.cpl", SetLastError = true)] private static extern int LaunchInternetControlPanel(HWND hWnd); /// Contains the global HTTP version. /// /// On Windows 7, Windows Server 2008 R2, and later, the value in the HTTP_VERSION_INFO structure is overridden by Internet Explorer /// settings. EnableHttp1_1 is a registry value under HKLM\Software\Microsoft\InternetExplorer\AdvacnedOptions\HTTP\GENABLE /// controlled by Internet Options set in Internet Explorer for the system. The EnableHttp1_1 value defaults to 1. The /// HTTP_VERSION_INFO structure is ignored for any HTTP version less than 1.1 if EnableHttp1_1 is set to 1. /// [StructLayout(LayoutKind.Sequential)] public struct HTTP_VERSION_INFO { /// The major version number. Must be 1. public uint dwMajorVersion; /// The minor version number. Can be either 1 or zero. public uint dwMinorVersion; } /// Contains the LastModified and Expire times for a resource stored in the Internet cache. [StructLayout(LayoutKind.Sequential)] public struct INTERNET_CACHE_TIMESTAMPS { /// FILETIME structure that contains the Expires time. public FILETIME ftExpires; /// FILETIME structure that contains the LastModified time. public FILETIME ftLastModified; } /// Contains certificate information returned from the server. This structure is used by the InternetQueryOption function. /// /// Despite what the header indicates, the implementation of INTERNET_CERTIFICATE_INFO is not Unicode-aware. All of the string /// members are filled as ANSI strings regardless of whether Unicode is enabled. Consequently, when reading these values, the caller /// must cast them to LPSTR if Unicode is enabled. /// [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct INTERNET_CERTIFICATE_INFO { /// FILETIME structure that contains the date the certificate expires. public FILETIME ftExpiry; /// FILETIME structure that contains the date the certificate becomes valid. public FILETIME ftStart; /// /// Pointer to a buffer that contains the name of the organization, site, and server for which the certificate was issued. The /// application must call LocalFree to release the resources allocated for this parameter. /// public StrPtrAnsi lpszSubjectInfo; /// /// Pointer to a buffer that contains the name of the organization, site, and server that issued the certificate. The application /// must call LocalFree to release the resources allocated for this parameter. /// public StrPtrAnsi lpszIssuerInfo; /// /// Pointer to a buffer that contains the name of the protocol used to provide the secure connection. The application must call /// LocalFree to release the resources allocated for this parameter. /// public StrPtrAnsi lpszProtocolName; /// /// Pointer to a buffer that contains the name of the algorithm used for signing the certificate. The application must call /// LocalFree to release the resources allocated for this parameter. /// public StrPtrAnsi lpszSignatureAlgName; /// /// Pointer to a buffer that contains the name of the algorithm used for doing encryption over the secure channel (SSL/PCT) /// connection. The application must call LocalFree to release the resources allocated for this parameter. /// public StrPtrAnsi lpszEncryptionAlgName; /// Size, in TCHARs, of the key. public uint dwKeySize; } /// /// The INTERNET_DIAGNOSTIC_SOCKET_INFO structure is returned by the InternetQueryOption function when the /// INTERNET_OPTION_DIAGNOSTIC_SOCKET_INFO flag is passed to it together with a handle to an HTTP Request. The /// INTERNET_DIAGNOSTIC_SOCKET_INFO structure contains information about the socket associated with that HTTP Request. /// [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct INTERNET_DIAGNOSTIC_SOCKET_INFO { /// Descriptor that identifies the socket associated with the specified HTTP Request. public IntPtr Socket; /// The address of the port at which the HTTP Request and response was received. public uint SourcePort; /// The address of the port at which the response was sent. public uint DestPort; /// The flags public IDSI_Flags Flags; } /// Contains the value of an option. [StructLayout(LayoutKind.Sequential)] public struct INTERNET_PER_CONN_OPTION { /// Option to be queried or set. public INTERNET_PER_CONN_OPTION_ID dwOption; /// /// Union that contains the value for the option. It can be any one of the following types depending on the value of dwOption. /// public INTERNET_PER_CONN_OPTION_Value Value; /// /// Union that contains the value for the option. It can be any one of the following types depending on the value of dwOption. /// [StructLayout(LayoutKind.Explicit)] public struct INTERNET_PER_CONN_OPTION_Value { /// Unsigned long integer value. [FieldOffset(0)] public uint dwValue; /// Pointer to a string value. [FieldOffset(0)] public StrPtrAuto pszValue; /// A FILETIME structure. [FieldOffset(0)] public FILETIME ftValue; } } /// Contains the list of options for a particular Internet connection. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct INTERNET_PER_CONN_OPTION_LIST { /// Size of the structure, in bytes. public uint dwSize; /// /// Pointer to a string that contains the name of the RAS connection or NULL, which indicates the default or LAN connection, to /// set or query options on. /// public StrPtrAuto pszConnection; /// Number of options to query or set. public uint dwOptionCount; /// Options that failed, if an error occurs. public uint dwOptionError; /// Pointer to an array of INTERNET_PER_CONN_OPTION structures containing the options to query or set. public IntPtr pOptions; } /// /// Contains information that is supplied with the INTERNET_OPTION_PROXY value to get or set proxy information on a handle obtained /// from a call to the InternetOpen function. /// [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct INTERNET_PROXY_INFO { /// Access type. public InternetOpenType dwAccessType; /// Pointer to a string that contains the proxy server list. public StrPtrAuto lpszProxy; /// Pointer to a string that contains the proxy bypass list. public StrPtrAuto lpszProxyBypass; } /// /// Contains the HTTP version number of the server. This structure is used when passing the INTERNET_OPTION_VERSION flag to the /// InternetQueryOption function. /// [StructLayout(LayoutKind.Sequential)] public struct INTERNET_VERSION_INFO { /// Major version number. public uint dwMajorVersion; /// Minor version number. public uint dwMinorVersion; } public class SafeInternetConnectHandle : SafeInternetHandle { /// Initializes a new instance of the class. public SafeInternetConnectHandle() { } /// Initializes a new instance of the class. /// An existing handle. /// if set to true owns and disposes of the handle. public SafeInternetConnectHandle(IntPtr hInternet, bool owns = true) : base(hInternet, owns) { } /// Performs an implicit conversion from to . /// The HINTERNET handle. /// The result of the conversion. public static implicit operator SafeInternetConnectHandle(IntPtr hInternet) => new SafeInternetConnectHandle(hInternet); } /// Provides a that is disposed using . public class SafeInternetHandle : HANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. /// to reliably release the handle during the finalization phase; otherwise, (not recommended). public SafeInternetHandle(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } /// Initializes a new instance of the class. protected SafeInternetHandle() : base() { } /// Represents a NULL value for this handle. public static readonly SafeInternetHandle Null = new SafeInternetHandle(); /// protected override bool InternalReleaseHandle() => InternetCloseHandle(this.DangerousGetHandle()); } } }