From 626991b3821ceae4d47aa93b1529b1e212047590 Mon Sep 17 00:00:00 2001 From: dahall Date: Thu, 14 Jul 2022 20:54:33 -0600 Subject: [PATCH] WinInet: Added missing HTTP_QUERY and HTTP_STATUS values, added overloads for HttpQueryInfo that don't require lpdwIndex param, fixed string handling bug in InternetSetOption. --- PInvoke/WinINet/WinINet.cs | 369 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 313 insertions(+), 56 deletions(-) diff --git a/PInvoke/WinINet/WinINet.cs b/PInvoke/WinINet/WinINet.cs index cd3206da..fc83a096 100644 --- a/PInvoke/WinINet/WinINet.cs +++ b/PInvoke/WinINet/WinINet.cs @@ -813,6 +813,12 @@ namespace Vanara.PInvoke /// Returns the data as a 32-bit number for headers whose value is a number, such as the status code. HTTP_QUERY_FLAG_NUMBER = 0x20000000, + /// + /// If this bit is set in the dwInfoLevel parameter of HttpQueryInfo(), then the values from several headers of the same name + /// will be combined using comma as the delimiter. + /// + HTTP_QUERY_FLAG_COALESCE_WITH_COMMA = 0x40000000, + /// Queries request headers only. HTTP_QUERY_FLAG_REQUEST_HEADERS = 0x80000000, @@ -823,6 +829,154 @@ namespace Vanara.PInvoke HTTP_QUERY_FLAG_SYSTEMTIME = 0x40000000, } + /// The HTTP status codes returned by servers on the Internet. + // https://docs.microsoft.com/en-us/windows/win32/wininet/http-status-codes + [PInvokeData("wininet.h")] + public enum HTTP_STATUS : uint + { + /// The request can be continued. + HTTP_STATUS_CONTINUE = 100, + + /// The server has switched protocols in an upgrade header. + HTTP_STATUS_SWITCH_PROTOCOLS = 101, + + /// The request completed successfully. + HTTP_STATUS_OK = 200, + + /// The request has been fulfilled and resulted in the creation of a new resource. + HTTP_STATUS_CREATED = 201, + + /// The request has been accepted for processing, but the processing has not been completed. + HTTP_STATUS_ACCEPTED = 202, + + /// The returned meta information in the entity-header is not the definitive set available from the origin server. + HTTP_STATUS_PARTIAL = 203, + + /// The server has fulfilled the request, but there is no new information to send back. + HTTP_STATUS_NO_CONTENT = 204, + + /// + /// The request has been completed, and the client program should reset the document view that caused the request to be sent to + /// allow the user to easily initiate another input action. + /// + HTTP_STATUS_RESET_CONTENT = 205, + + /// The server has fulfilled the partial GET request for the resource. + HTTP_STATUS_PARTIAL_CONTENT = 206, + + /// The server couldn't decide what to return. + HTTP_STATUS_AMBIGUOUS = 300, + + /// + /// The requested resource has been assigned to a new permanent URI (Uniform Resource Identifier), and any future references to + /// this resource should be done using one of the returned URIs. + /// + HTTP_STATUS_MOVED = 301, + + /// The requested resource resides temporarily under a different URI (Uniform Resource Identifier). + HTTP_STATUS_REDIRECT = 302, + + /// + /// The response to the request can be found under a different URI (Uniform Resource Identifier) and should be retrieved using a + /// GET HTTP verb on that resource. + /// + HTTP_STATUS_REDIRECT_METHOD = 303, + + /// The requested resource has not been modified. + HTTP_STATUS_NOT_MODIFIED = 304, + + /// The requested resource must be accessed through the proxy given by the location field. + HTTP_STATUS_USE_PROXY = 305, + + /// The redirected request keeps the same HTTP verb. HTTP/1.1 behavior. + HTTP_STATUS_REDIRECT_KEEP_VERB = 307, + + /// The request could not be processed by the server due to invalid syntax. + HTTP_STATUS_BAD_REQUEST = 400, + + /// The requested resource requires user authentication. + HTTP_STATUS_DENIED = 401, + + /// Not currently implemented in the HTTP protocol. + HTTP_STATUS_PAYMENT_REQ = 402, + + /// The server understood the request, but is refusing to fulfill it. + HTTP_STATUS_FORBIDDEN = 403, + + /// The server has not found anything matching the requested URI (Uniform Resource Identifier). + HTTP_STATUS_NOT_FOUND = 404, + + /// The HTTP verb used is not allowed. + HTTP_STATUS_BAD_METHOD = 405, + + /// No responses acceptable to the client were found. + HTTP_STATUS_NONE_ACCEPTABLE = 406, + + /// Proxy authentication required. + HTTP_STATUS_PROXY_AUTH_REQ = 407, + + /// The server timed out waiting for the request. + HTTP_STATUS_REQUEST_TIMEOUT = 408, + + /// + /// The request could not be completed due to a conflict with the current state of the resource. The user should resubmit with + /// more information. + /// + HTTP_STATUS_CONFLICT = 409, + + /// The requested resource is no longer available at the server, and no forwarding address is known. + HTTP_STATUS_GONE = 410, + + /// The server refuses to accept the request without a defined content length. + HTTP_STATUS_LENGTH_REQUIRED = 411, + + /// + /// The precondition given in one or more of the request header fields evaluated to false when it was tested on the server. + /// + HTTP_STATUS_PRECOND_FAILED = 412, + + /// + /// The server is refusing to process a request because the request entity is larger than the server is willing or able to process. + /// + HTTP_STATUS_REQUEST_TOO_LARGE = 413, + + /// + /// The server is refusing to service the request because the request URI (Uniform Resource Identifier) is longer than the server + /// is willing to interpret. + /// + HTTP_STATUS_URI_TOO_LONG = 414, + + /// + /// The server is refusing to service the request because the entity of the request is in a format not supported by the requested + /// resource for the requested method. + /// + HTTP_STATUS_UNSUPPORTED_MEDIA = 415, + + /// The request should be retried after doing the appropriate action. + HTTP_STATUS_RETRY_WITH = 449, + + /// The server encountered an unexpected condition that prevented it from fulfilling the request. + HTTP_STATUS_SERVER_ERROR = 500, + + /// The server does not support the functionality required to fulfill the request. + HTTP_STATUS_NOT_SUPPORTED = 501, + + /// + /// The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in + /// attempting to fulfill the request. + /// + HTTP_STATUS_BAD_GATEWAY = 502, + + /// The service is temporarily overloaded. + HTTP_STATUS_SERVICE_UNAVAIL = 503, + + /// The request was timed out waiting for a gateway. + HTTP_STATUS_GATEWAY_TIMEOUT = 504, + + /// The server does not support, or refuses to support, the HTTP protocol version that was used in the request message. + HTTP_STATUS_VERSION_NOT_SUP = 505, + } + /// Controls canonicalization. [PInvokeData("wininet.h", MSDNShortId = "3bfde980-e478-4960-b41f-e1c8105ef419")] [Flags] @@ -3348,39 +3502,37 @@ namespace Vanara.PInvoke /// public static IEnumerable FindUrlCacheEntries(string lpszUrlSearchPattern = null) { - using (var mem = new SafeHGlobalHandle(1024)) + using var mem = new SafeHGlobalHandle(1024); + uint sz = mem.Size; + var h = FindFirstUrlCacheEntry(lpszUrlSearchPattern, mem, ref sz); + if (h.IsNull) { - uint sz = mem.Size; - var h = FindFirstUrlCacheEntry(lpszUrlSearchPattern, mem, ref sz); - if (h.IsNull) + Win32Error.ThrowLastErrorUnless(Win32Error.ERROR_INSUFFICIENT_BUFFER); + mem.Size = sz; + h = FindFirstUrlCacheEntry(lpszUrlSearchPattern, mem, ref sz); + if (h.IsNull) Win32Error.ThrowLastError(); + } + yield return new INTERNET_CACHE_ENTRY_INFO_MGD(mem.ToStructure()); + try + { + do { - Win32Error.ThrowLastErrorUnless(Win32Error.ERROR_INSUFFICIENT_BUFFER); - mem.Size = sz; - h = FindFirstUrlCacheEntry(lpszUrlSearchPattern, mem, ref sz); - if (h.IsNull) Win32Error.ThrowLastError(); - } - yield return new INTERNET_CACHE_ENTRY_INFO_MGD(mem.ToStructure()); - try - { - do + if (!FindNextUrlCacheEntry(h, mem, ref sz)) { + var err = Win32Error.GetLastError(); + if (err == Win32Error.ERROR_NO_MORE_ITEMS) + break; + err.ThrowUnless(Win32Error.ERROR_INSUFFICIENT_BUFFER); + mem.Size = sz; if (!FindNextUrlCacheEntry(h, mem, ref sz)) - { - var err = Win32Error.GetLastError(); - if (err == Win32Error.ERROR_NO_MORE_ITEMS) - break; - err.ThrowUnless(Win32Error.ERROR_INSUFFICIENT_BUFFER); - mem.Size = sz; - if (!FindNextUrlCacheEntry(h, mem, ref sz)) - Win32Error.ThrowLastErrorUnless(Win32Error.ERROR_NO_MORE_ITEMS); - } - yield return new INTERNET_CACHE_ENTRY_INFO_MGD(mem.ToStructure()); - } while (true); - } - finally - { - FindCloseUrlCache(h); - } + Win32Error.ThrowLastErrorUnless(Win32Error.ERROR_NO_MORE_ITEMS); + } + yield return new INTERNET_CACHE_ENTRY_INFO_MGD(mem.ToStructure()); + } while (true); + } + finally + { + FindCloseUrlCache(h); } } @@ -4975,6 +5127,77 @@ namespace Vanara.PInvoke [return: MarshalAs(UnmanagedType.Bool)] public static extern bool HttpQueryInfo(HINTERNET hRequest, HTTP_QUERY dwInfoLevel, IntPtr lpBuffer, ref uint lpdwBufferLength, ref uint lpdwIndex); + /// Retrieves header information associated with an HTTP request. + /// A handle returned by a call to the HttpOpenRequest or InternetOpenUrl function. + /// + /// A combination of an attribute to be retrieved and flags that modify the request. For a list of possible attribute and modifier + /// values, see Query Info Flags. + /// + /// A pointer to a buffer to receive the requested information. This parameter must not be NULL. + /// + /// A pointer to a variable that contains, on entry, the size in bytes of the buffer pointed to by lpvBuffer. + /// + /// When the function returns successfully, this variable contains the number of bytes of information written to the buffer. In the + /// case of a string, the byte count does not include the string's terminating null character. + /// + /// + /// When the function fails with an extended error code of ERROR_INSUFFICIENT_BUFFER, the variable pointed to by + /// lpdwBufferLength contains on exit the size, in bytes, of a buffer large enough to receive the requested information. The calling + /// application can then allocate a buffer of this size or larger, and call the function again. + /// + /// + /// + /// A pointer to a zero-based header index used to enumerate multiple headers with the same name. When calling the function, this + /// parameter is the index of the specified header to return. When the function returns, this parameter is the index of the next + /// header. If the next index cannot be found, ERROR_HTTP_HEADER_NOT_FOUND is returned. + /// + /// Returns TRUE if successful, or FALSE otherwise. To get extended error information, call GetLastError. + /// + /// You can retrieve the following types of data from HttpQueryInfo: + /// + /// + /// Strings (default) + /// + /// + /// SYSTEMTIME (for dates) + /// + /// + /// DWORD (for STATUS_CODE, CONTENT_LENGTH, and so on, if HTTP_QUERY_FLAG_NUMBER has been used) + /// + /// + /// + /// If your application requires that the data be returned as a data type other than a string, you must include the appropriate + /// modifier with the attribute passed to dwInfoLevel. + /// + /// + /// The HttpQueryInfo function is available in Microsoft Internet Explorer 3.0 for ISO-8859-1 characters ( + /// HttpQueryInfoA function) and in Internet Explorer 4.0 or later for ISO-8859-1 characters ( HttpQueryInfoA + /// function) and for ISO-8859-1 characters converted to UTF-16LE characters.(the HttpQueryInfoW function). + /// + /// + /// Note The HttpQueryInfoA function represents headers as ISO-8859-1 characters not ANSI characters. The + /// HttpQueryInfoW function represents headers as ISO-8859-1 characters converted to UTF-16LE characters. As a result, it is + /// never safe to use the HttpQueryInfoW function when the headers can contain non-ASCII characters. Instead, an application + /// can use the MultiByteToWideChar and WideCharToMultiByte functions with a Codepage parameter set to 28591 to map between ANSI + /// characters and UTF-16LE characters. + /// + /// See Retrieving HTTP Headers for an example code calling the HttpQueryInfo function. + /// + /// Like all other aspects of the WinINet API, this function cannot be safely called from within DllMain or the constructors and + /// destructors of global objects. + /// + /// + /// Note WinINet does not support server implementations. In addition, it should not be used from a service. For server + /// implementations or services use Microsoft Windows HTTP Services (WinHTTP). + /// + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wininet/nf-wininet-httpqueryinfoa BOOLAPI HttpQueryInfoA( HINTERNET hRequest, + // DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex ); + [DllImport(Lib.WinInet, SetLastError = true, CharSet = CharSet.Auto)] + [PInvokeData("wininet.h", MSDNShortId = "5747ce19-5004-4eea-abe9-dd00abac1b3b")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool HttpQueryInfo(HINTERNET hRequest, HTTP_QUERY dwInfoLevel, IntPtr lpBuffer, ref uint lpdwBufferLength, [In, Optional] IntPtr lpdwIndex); + /// Retrieves header information associated with an HTTP request. /// A handle returned by a call to the HttpOpenRequest or InternetOpenUrl function. /// @@ -4993,11 +5216,28 @@ namespace Vanara.PInvoke { var sz = 0U; HttpQueryInfo(hRequest, dwInfoLevel, IntPtr.Zero, ref sz, ref lpdwIndex); - var err = Win32Error.GetLastError(); - if (err != Win32Error.ERROR_INSUFFICIENT_BUFFER) err.ThrowIfFailed(); + Win32Error.ThrowLastErrorUnless(Win32Error.ERROR_INSUFFICIENT_BUFFER); var hMem = new SafeCoTaskMemHandle(sz); - var res = HttpQueryInfo(hRequest, dwInfoLevel, hMem, ref sz, ref lpdwIndex); - if (!res) Win32Error.ThrowLastError(); + Win32Error.ThrowLastErrorIfFalse(HttpQueryInfo(hRequest, dwInfoLevel, hMem, ref sz, ref lpdwIndex)); + return hMem; + } + + /// Retrieves header information associated with an HTTP request. + /// A handle returned by a call to the HttpOpenRequest or InternetOpenUrl function. + /// + /// A combination of an attribute to be retrieved and flags that modify the request. For a list of possible attribute and modifier + /// values, see Query Info Flags. + /// + /// + /// A instance with sufficient memory needed to hold the response. This should be cast to the type required. + /// + public static ISafeMemoryHandle HttpQueryInfo(HINTERNET hRequest, HTTP_QUERY dwInfoLevel) + { + var sz = 0U; + HttpQueryInfo(hRequest, dwInfoLevel, IntPtr.Zero, ref sz); + Win32Error.ThrowLastErrorUnless(Win32Error.ERROR_INSUFFICIENT_BUFFER); + var hMem = new SafeCoTaskMemHandle(sz); + Win32Error.ThrowLastErrorIfFalse(HttpQueryInfo(hRequest, dwInfoLevel, hMem, ref sz)); return hMem; } @@ -5019,8 +5259,25 @@ namespace Vanara.PInvoke /// The HTTP information. public static T HttpQueryInfo(HINTERNET hRequest, HTTP_QUERY dwInfoLevel, ref uint lpdwIndex) { - using (var hMem = HttpQueryInfo(hRequest, dwInfoLevel, ref lpdwIndex)) - return typeof(T) == typeof(string) ? (T)(object)hMem.ToString(-1) : (typeof(T) == typeof(bool) ? (T)(object)Convert.ToBoolean(hMem.ToStructure()) : hMem.ToStructure()); + using ISafeMemoryHandle hMem = HttpQueryInfo(hRequest, dwInfoLevel, ref lpdwIndex); + return typeof(T) == typeof(string) ? (T)(object)hMem.ToString(-1) : (typeof(T) == typeof(bool) ? (T)(object)Convert.ToBoolean(hMem.ToStructure()) : hMem.ToStructure()); + } + + /// Retrieves header information associated with an HTTP request. + /// + /// Return type. This should be, by default, a unless one of the return type modification flags is passed into + /// . + /// + /// A handle returned by a call to the HttpOpenRequest or InternetOpenUrl function. + /// + /// A combination of an attribute to be retrieved and flags that modify the request. For a list of possible attribute and modifier + /// values, see Query Info Flags. + /// + /// The HTTP information. + public static T HttpQueryInfo(HINTERNET hRequest, HTTP_QUERY dwInfoLevel) + { + using ISafeMemoryHandle hMem = HttpQueryInfo(hRequest, dwInfoLevel); + return typeof(T) == typeof(string) ? (T)(object)hMem.ToString(-1) : (typeof(T) == typeof(bool) ? (T)(object)Convert.ToBoolean(hMem.ToStructure()) : hMem.ToStructure()); } /// @@ -7183,8 +7440,8 @@ namespace Vanara.PInvoke public static T InternetQueryOption(HINTERNET hInternet, InternetOptionFlags option) { if (!CorrespondingTypeAttribute.CanGet(option, typeof(T))) throw new ArgumentException($"{option} cannot be used to get values of type {typeof(T)}."); - using (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()); + using 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()); } /// Reads data from a handle opened by the InternetOpenUrl, FtpOpenFile, or HttpOpenRequest function. @@ -7568,8 +7825,8 @@ namespace Vanara.PInvoke public static bool InternetSetOption(HINTERNET 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)}."); - using (var hMem = typeof(T) == typeof(string) ? new SafeCoTaskMemHandle(value?.ToString()) : (typeof(T) == typeof(bool) ? SafeCoTaskMemHandle.CreateFromStructure(Convert.ToUInt32(value)) : SafeCoTaskMemHandle.CreateFromStructure(value))) - return InternetSetOption(hInternet, option, hMem, typeof(T) == typeof(string) ? value?.ToString().Length + 1 ?? 0 : (int)hMem.Size); + using SafeAllocatedMemoryHandle hMem = typeof(T) == typeof(string) ? new SafeCoTaskMemString(value?.ToString(), CharSet.Auto) : (typeof(T) == typeof(bool) ? SafeCoTaskMemHandle.CreateFromStructure(Convert.ToUInt32(value)) : SafeCoTaskMemHandle.CreateFromStructure(value)); + return InternetSetOption(hInternet, option, hMem, typeof(T) == typeof(string) ? value?.ToString().Length + 1 ?? 0 : (int)hMem.Size); } /// @@ -8741,14 +8998,14 @@ namespace Vanara.PInvoke [StructLayout(LayoutKind.Sequential)] public struct HCACHEENTRYSTREAM : IHandle { - private IntPtr handle; + private readonly IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HCACHEENTRYSTREAM(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . - public static HCACHEENTRYSTREAM NULL => new HCACHEENTRYSTREAM(IntPtr.Zero); + public static HCACHEENTRYSTREAM NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; @@ -8761,7 +9018,7 @@ namespace Vanara.PInvoke /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. - public static implicit operator HCACHEENTRYSTREAM(IntPtr h) => new HCACHEENTRYSTREAM(h); + public static implicit operator HCACHEENTRYSTREAM(IntPtr h) => new(h); /// Implements the operator !=. /// The first handle. @@ -8776,7 +9033,7 @@ namespace Vanara.PInvoke public static bool operator ==(HCACHEENTRYSTREAM h1, HCACHEENTRYSTREAM h2) => h1.Equals(h2); /// - public override bool Equals(object obj) => obj is HCACHEENTRYSTREAM h ? handle == h.handle : false; + public override bool Equals(object obj) => obj is HCACHEENTRYSTREAM h &&handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); @@ -8796,7 +9053,7 @@ namespace Vanara.PInvoke public HFINDCACHE(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . - public static HFINDCACHE NULL => new HFINDCACHE(IntPtr.Zero); + public static HFINDCACHE NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; @@ -8809,7 +9066,7 @@ namespace Vanara.PInvoke /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. - public static implicit operator HFINDCACHE(IntPtr h) => new HFINDCACHE(h); + public static implicit operator HFINDCACHE(IntPtr h) => new(h); /// Implements the operator !=. /// The first handle. @@ -8824,7 +9081,7 @@ namespace Vanara.PInvoke public static bool operator ==(HFINDCACHE h1, HFINDCACHE h2) => h1.Equals(h2); /// - public override bool Equals(object obj) => obj is HFINDCACHE h ? handle == h.handle : false; + public override bool Equals(object obj) => obj is HFINDCACHE h &&handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); @@ -8844,7 +9101,7 @@ namespace Vanara.PInvoke public HINTERNET(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . - public static HINTERNET NULL => new HINTERNET(IntPtr.Zero); + public static HINTERNET NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; @@ -8857,7 +9114,7 @@ namespace Vanara.PInvoke /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. - public static implicit operator HINTERNET(IntPtr h) => new HINTERNET(h); + public static implicit operator HINTERNET(IntPtr h) => new(h); /// Implements the operator !=. /// The first handle. @@ -8872,7 +9129,7 @@ namespace Vanara.PInvoke public static bool operator ==(HINTERNET h1, HINTERNET h2) => h1.Equals(h2); /// - public override bool Equals(object obj) => obj is HINTERNET h ? handle == h.handle : false; + public override bool Equals(object obj) => obj is HINTERNET h &&handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); @@ -8908,7 +9165,7 @@ namespace Vanara.PInvoke public IntPtr dwContext; /// The default instance of INTERNET_AUTH_NOTIFY_DATA with cbStruct set. - public static readonly INTERNET_AUTH_NOTIFY_DATA Default = new INTERNET_AUTH_NOTIFY_DATA { cbStruct = (uint)Marshal.SizeOf(typeof(INTERNET_AUTH_NOTIFY_DATA)) }; + public static readonly INTERNET_AUTH_NOTIFY_DATA Default = new() { cbStruct = (uint)Marshal.SizeOf(typeof(INTERNET_AUTH_NOTIFY_DATA)) }; } /// Contains both the data and header information. @@ -8954,7 +9211,7 @@ namespace Vanara.PInvoke public uint dwOffsetHigh; /// The default instance of INTERNET_BUFFERS with dwStructSize set. - public static readonly INTERNET_BUFFERS Default = new INTERNET_BUFFERS { dwStructSize = (uint)Marshal.SizeOf(typeof(INTERNET_BUFFERS)) }; + public static readonly INTERNET_BUFFERS Default = new() { dwStructSize = (uint)Marshal.SizeOf(typeof(INTERNET_BUFFERS)) }; } /// Contains information about the configuration of the Internet cache. @@ -9003,7 +9260,7 @@ namespace Vanara.PInvoke public uint dwExemptUsage; /// The default instance of INTERNET_CACHE_CONFIG_INFO with dwStructSize set. - public static readonly INTERNET_CACHE_CONFIG_INFO Default = new INTERNET_CACHE_CONFIG_INFO { dwStructSize = (uint)Marshal.SizeOf(typeof(INTERNET_CACHE_CONFIG_INFO)) }; + public static readonly INTERNET_CACHE_CONFIG_INFO Default = new() { dwStructSize = (uint)Marshal.SizeOf(typeof(INTERNET_CACHE_CONFIG_INFO)) }; } /// Entry in INTERNET_CACHE_CONFIG_INFO. @@ -9155,7 +9412,7 @@ namespace Vanara.PInvoke public uint dwExemptDelta; /// The default instance of INTERNET_CACHE_ENTRY_INFO with dwStructSize set. - public static readonly INTERNET_CACHE_ENTRY_INFO Default = new INTERNET_CACHE_ENTRY_INFO { dwStructSize = (uint)Marshal.SizeOf(typeof(INTERNET_CACHE_ENTRY_INFO)) }; + public static readonly INTERNET_CACHE_ENTRY_INFO Default = new() { dwStructSize = (uint)Marshal.SizeOf(typeof(INTERNET_CACHE_ENTRY_INFO)) }; } /// Contains information about an entry in the Internet cache. @@ -9494,7 +9751,7 @@ namespace Vanara.PInvoke public IntPtr pOptions; /// The default instance of INTERNET_PER_CONN_OPTION_LIST with dwSize set. - public static readonly INTERNET_PER_CONN_OPTION_LIST Default = new INTERNET_PER_CONN_OPTION_LIST { dwSize = (uint)Marshal.SizeOf(typeof(INTERNET_PER_CONN_OPTION_LIST)) }; + public static readonly INTERNET_PER_CONN_OPTION_LIST Default = new() { dwSize = (uint)Marshal.SizeOf(typeof(INTERNET_PER_CONN_OPTION_LIST)) }; } /// @@ -9604,7 +9861,7 @@ namespace Vanara.PInvoke public uint dwExtraInfoLength; /// The default instance of URL_COMPONENTS with dwStructSize set. - public static readonly URL_COMPONENTS Default = new URL_COMPONENTS { dwStructSize = (uint)Marshal.SizeOf(typeof(URL_COMPONENTS)) }; + public static readonly URL_COMPONENTS Default = new() { dwStructSize = (uint)Marshal.SizeOf(typeof(URL_COMPONENTS)) }; } /// Provides a for that is disposed using . @@ -9643,7 +9900,7 @@ namespace Vanara.PInvoke internal SafeHINTERNET() : base() { } /// Represents a NULL value for this handle. - public static SafeHINTERNET Null => new SafeHINTERNET(); + public static SafeHINTERNET Null => new(); /// Performs an implicit conversion from to . /// The safe handle instance.