Added new functions introducted in Win11

pull/350/head
David Hall 2022-10-25 11:24:37 -06:00
parent f60a379236
commit 17acbee104
7 changed files with 4519 additions and 3724 deletions

View File

@ -5,6 +5,29 @@ namespace Vanara.PInvoke
{ {
public static partial class Kernel32 public static partial class Kernel32
{ {
/// <summary>Undocumented</summary>
[PInvokeData("winbase.h", MinClient = PInvokeClient.Windows11)]
public enum FILE_FLUSH_MODE
{
/// <summary>same as WIN32 FlushFileBuffers(); Flushes data, metadata, AND sends a SYNC command to the hardware</summary>
FILE_FLUSH_DEFAULT = 0,
/// <summary>Flush data only</summary>
FILE_FLUSH_DATA,
/// <summary>Flush data + SYNC (minimal metadata)</summary>
FILE_FLUSH_MIN_METADATA,
/// <summary>Flush data + metadata</summary>
FILE_FLUSH_NO_SYNC,
}
/// <summary>Undocumented</summary>
[PInvokeData("winbase.h", MinClient = PInvokeClient.Windows11)]
public enum FILE_WRITE_FLAGS
{
/// <summary>Undocumented</summary>
FILE_WRITE_FLAGS_NONE,
/// <summary>Undocumented</summary>
FILE_WRITE_FLAGS_WRITE_THROUGH = 0x000000001,
}
/// <summary>Specifies advisory flags for creating an I/O ring with a call to CreateIoRing.</summary> /// <summary>Specifies advisory flags for creating an I/O ring with a call to CreateIoRing.</summary>
/// <remarks> /// <remarks>
/// Use the IORING_CREATE_FLAGS structure to pass flags into <c>CreateIoRing</c>. Any unknown or unsupported advisory flags provided /// Use the IORING_CREATE_FLAGS structure to pass flags into <c>CreateIoRing</c>. Any unknown or unsupported advisory flags provided
@ -115,6 +138,52 @@ namespace Vanara.PInvoke
[PInvokeData("ioringapi.h", MSDNShortId = "NF:ioringapi.BuildIoRingCancelRequest", MinClient = PInvokeClient.Windows11)] [PInvokeData("ioringapi.h", MSDNShortId = "NF:ioringapi.BuildIoRingCancelRequest", MinClient = PInvokeClient.Windows11)]
public static extern HRESULT BuildIoRingCancelRequest(HIORING ioRing, IORING_HANDLE_REF file, IntPtr opToCancel, [In, Optional] IntPtr userData); public static extern HRESULT BuildIoRingCancelRequest(HIORING ioRing, IORING_HANDLE_REF file, IntPtr opToCancel, [In, Optional] IntPtr userData);
/// <summary>Undocumented.</summary>
/// <param name="ioRing">An <c>HIORING</c> representing a handle to the I/O ring for which a cancellation is requested.</param>
/// <param name="fileRef">An IORING_HANDLE_REF representing the file associated with the operation to flush.</param>
/// <param name="flushMode">The flush mode.</param>
/// <param name="userData">
/// A UINT_PTR value identifying the file write operation. Specify this value when cancelling the operation with a call to
/// BuildIoRingCancelRequest. If an app implements cancellation behavior for the operation, the userData value must be unique.
/// Otherwise, the value is treated as opaque by the system and can be anything, including 0.
/// </param>
/// <param name="sqeFlags">
/// A bitwise OR combination of values from the IORING_SQE_FLAGS enumeration specifying kernel behavior options for I/O ring
/// submission queue entries.
/// </param>
/// <returns>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>Success</term>
/// </item>
/// <item>
/// <term>IORING_E_SUBMISSION_QUEUE_FULL</term>
/// <term>
/// The submission queue is full, and no additional entries are available to build. The application must submit the existing entries
/// and wait for some of them to complete before adding more operations to the queue.
/// </term>
/// </item>
/// <item>
/// <term>IORING_E_UNKNOWN_REQUIRED_FLAG</term>
/// <term>
/// The application provided a required flag that is not known to the implementation. Library code should check the IoRingVersion
/// field of the IORING_INFO obtained from a call to GetIoRingInfo to determine the API version of an I/O ring which determines the
/// operations and flags that are supported. Applications should know the version they used to create the I/O ring and therefore
/// should not provide unsupported flags at runtime.
/// </term>
/// </item>
/// </list>
/// </returns>
[DllImport(Lib.KernelBase, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ioringapi.h", MinClient = PInvokeClient.Windows11)]
public static extern HRESULT BuildIoRingFlushFile([In] HIORING ioRing, IORING_HANDLE_REF fileRef, FILE_FLUSH_MODE flushMode,
IntPtr userData, IORING_SQE_FLAGS sqeFlags);
/// <summary>Performs an asynchronous read from a file using an I/O ring. This operation is similar to calling ReadFileEx.</summary> /// <summary>Performs an asynchronous read from a file using an I/O ring. This operation is similar to calling ReadFileEx.</summary>
/// <param name="ioRing">An <c>HIORING</c> representing a handle to the I/O ring which will perform the read operation.</param> /// <param name="ioRing">An <c>HIORING</c> representing a handle to the I/O ring which will perform the read operation.</param>
/// <param name="fileRef">An IORING_HANDLE_REF specifying the file to read.</param> /// <param name="fileRef">An IORING_HANDLE_REF specifying the file to read.</param>
@ -275,6 +344,61 @@ namespace Vanara.PInvoke
public static extern HRESULT BuildIoRingRegisterFileHandles(HIORING ioRing, uint count, public static extern HRESULT BuildIoRingRegisterFileHandles(HIORING ioRing, uint count,
[In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] HANDLE[] handles, [In, Optional] IntPtr userData); [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] HANDLE[] handles, [In, Optional] IntPtr userData);
/// <summary>Undocumented. Performs an asynchronous write to a file using an I/O ring. This operation is similar to calling WriteFileEx.</summary>
/// <param name="ioRing">An <c>HIORING</c> representing a handle to the I/O ring for which a cancellation is requested.</param>
/// <param name="fileRef">An IORING_HANDLE_REF specifying the file to write.</param>
/// <param name="bufferRef">
/// An IORING_BUFFER_REF specifying the buffer into which the file is write. The provided buffer must have a size of at least
/// numberOfBytesToRead bytes.
/// </param>
/// <param name="numberOfBytesToWrite">The number of bytes to write.</param>
/// <param name="fileOffset">The offset into the file to begin reading.</param>
/// <param name="writeFlags">The write flags.</param>
/// <param name="userData">
/// A UINT_PTR value identifying the file write operation. Specify this value when cancelling the operation with a call to
/// BuildIoRingCancelRequest. If an app implements cancellation behavior for the operation, the userData value must be unique.
/// Otherwise, the value is treated as opaque by the system and can be anything, including 0.
/// </param>
/// <param name="sqeFlags">
/// A bitwise OR combination of values from the IORING_SQE_FLAGS enumeration specifying kernel behavior options for I/O ring
/// submission queue entries.
/// </param>
/// <returns>
/// <para>Returns an HRESULT including, but not limited to the following:</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>Success</term>
/// </item>
/// <item>
/// <term>IORING_E_SUBMISSION_QUEUE_FULL</term>
/// <term>
/// The submission queue is full, and no additional entries are available to build. The application must submit the existing entries
/// and wait for some of them to complete before adding more operations to the queue.
/// </term>
/// </item>
/// <item>
/// <term>IORING_E_UNKNOWN_REQUIRED_FLAG</term>
/// <term>
/// The application provided a required flag that is not known to the implementation. Library code should check the IoRingVersion
/// field of the IORING_INFO obtained from a call to GetIoRingInfo to determine the API version of an I/O ring which determines the
/// operations and flags that are supported. Applications should know the version they used to create the I/O ring and therefore
/// should not provide unsupported flags at runtime.
/// </term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// Check I/O ring support for read file operations by calling IsIoRingOpSupported and specifying IORING_OP_WRITE for the op parameter.
/// </remarks>
[DllImport(Lib.KernelBase, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ioringapi.h", MinClient = PInvokeClient.Windows11)]
public static extern HRESULT BuildIoRingWriteFile([In] HIORING ioRing, IORING_HANDLE_REF fileRef, IORING_BUFFER_REF bufferRef,
uint numberOfBytesToWrite, ulong fileOffset, FILE_WRITE_FLAGS writeFlags, IntPtr userData, IORING_SQE_FLAGS sqeFlags);
/// <summary>Closes an <c>HIORING</c> handle that was previously opened with a call to CreateIoRing.</summary> /// <summary>Closes an <c>HIORING</c> handle that was previously opened with a call to CreateIoRing.</summary>
/// <param name="ioRing">The <c>HIORING</c> handle to close.</param> /// <param name="ioRing">The <c>HIORING</c> handle to close.</param>
/// <returns>Returns S_OK on success.</returns> /// <returns>Returns S_OK on success.</returns>
@ -462,6 +586,53 @@ namespace Vanara.PInvoke
[PInvokeData("ioringapi.h", MSDNShortId = "NF:ioringapi.QueryIoRingCapabilities", MinClient = PInvokeClient.Windows11)] [PInvokeData("ioringapi.h", MSDNShortId = "NF:ioringapi.QueryIoRingCapabilities", MinClient = PInvokeClient.Windows11)]
public static extern HRESULT QueryIoRingCapabilities(out IORING_CAPABILITIES capabilities); public static extern HRESULT QueryIoRingCapabilities(out IORING_CAPABILITIES capabilities);
/// <summary>Registers a completion queue event with an I/O ring.</summary>
/// <param name="ioRing">An <c>HIORING</c> representing a handle to the I/O ring for which the completion event is registered.</param>
/// <param name="hEvent">A handle to the event object. The CreateEvent or OpenEvent function returns this handle.</param>
/// <returns>
/// <para>Returns an HRESULT including the following values:</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>S_OK</term>
/// <term>Success</term>
/// </item>
/// <item>
/// <term>E_INVALID_HANDLE</term>
/// <term>An invalid handle was passed in the <c>ioRing</c> parameter.</term>
/// </item>
/// <item>
/// <term>E_INVALIDARG</term>
/// <term>An invalid handle was passed in the <c>hEvent</c> parameter.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// The kernel will signal this event when it places the first entry into an empty completion queue, i.e. the kernel only sets the
/// event to the signaled state when the completion queue transitions from the empty to non-empty state. Applications should call
/// PopIoRingCompletion until it indicates no more entries and then wait for any additional async completions to complete via the
/// provided HANDLE. Otherwise, the event wont enter the signaled state and the wait may block until a timeout occurs, or forever if
/// an infinite timeout is used.
/// </para>
/// <para>
/// The kernel will internally duplicate the handle, so it is safe for the application to close the handle when waits are no longer
/// needed. Providing an event handle value of NULL simply clears any existing value. Setting a value of INVALID_HANDLE_VALUE raises
/// an error, as will any other invalid handle value, to aid in detecting code bugs early.
/// </para>
/// <para>
/// There is, at most, one event handle associated with an HIORING, attempting to set a second one will replace any that already exists.
/// </para>
/// </remarks>
// https://learn.microsoft.com/en-us/windows/win32/api/ioringapi/nf-ioringapi-setioringcompletionevent
// HRESULT SetIoRingCompletionEvent( HIORING ioRing, HANDLE hEvent );
[PInvokeData("ioringapi.h", MSDNShortId = "NF:ioringapi.SetIoRingCompletionEvent")]
[DllImport(Lib.KernelBase, SetLastError = false, ExactSpelling = true)]
public static extern HRESULT SetIoRingCompletionEvent(HIORING ioRing, HEVENT hEvent);
/// <summary> /// <summary>
/// Submits all constructed but not yet submitted entries to the kernels queue and optionally waits for a set of operations to complete. /// Submits all constructed but not yet submitted entries to the kernels queue and optionally waits for a set of operations to complete.
/// </summary> /// </summary>

View File

@ -12,7 +12,7 @@ public static partial class Qwave
/// </summary> /// </summary>
public const ulong QOS_OUTGOING_DEFAULT_MINIMUM_BANDWIDTH = 0xFFFFFFFF; public const ulong QOS_OUTGOING_DEFAULT_MINIMUM_BANDWIDTH = 0xFFFFFFFF;
/// <summary>Flags used by <see cref="QOSAddSocketToFlow"/>.</summary> /// <summary>Flags used by <see cref="QOSAddSocketToFlow(HQOS, SOCKET, SOCKADDR, QOS_TRAFFIC_TYPE, QOS_FLOW_TYPE, ref QOS_FLOWID)"/>.</summary>
[PInvokeData("qos2.h")] [PInvokeData("qos2.h")]
public enum QOS_FLOW_TYPE public enum QOS_FLOW_TYPE
{ {

View File

@ -5927,6 +5927,111 @@ namespace Vanara.PInvoke
[PInvokeData("winuser.h", MSDNShortId = "")] [PInvokeData("winuser.h", MSDNShortId = "")]
public static extern HWND SetActiveWindow(HWND hWnd); public static extern HWND SetActiveWindow(HWND hWnd);
/// <summary>
/// <note type="warning"><c>SetAdditionalForegroundBoostProcesses</c> is a <c>limited access feature</c>. Contact
/// foregroundboostprocs@microsoft.com for more information.</note>
/// <para>
/// SetAdditionalForegroundBoostProcesses is a performance assist API to help applications with a multi-process application model
/// where multiple processes contribute to a foreground experience, either as data or rendering. Examples include browsers (with the
/// browser manager or frame, tabs, plugins, etc. hosted in different processes) and IDEs (which spawn processes for compilation and
/// other tasks).
/// </para>
/// <para>
/// Applications can use this API to provide a foreground priority boost to worker processes that help support the main application.
/// Such applications can have a uniform priority boost applied to all of their constituent processes when the application's top
/// level window is in the foreground.
/// </para>
/// </summary>
/// <param name="topLevelWindow">A handle to the top level window (HWND) of the application.</param>
/// <param name="processHandleCount">
/// The number of process handles in <c>processHandleArray</c>. This function can be called at a single time with a maximum of 32
/// handles. Set this parameter to <c>0</c> along with setting <c>processHandleArray</c> to <c>NULL</c> to clear a prior boost configuration.
/// </param>
/// <param name="processHandleArray">
/// A group of process handles to be foreground boosted or de-boosted. Set this parameter to <c>NULL</c> along with setting
/// <c>processHandleCount</c> to <c>0</c> to clear a prior boost configuration.
/// </param>
/// <returns>
/// Returns <c>TRUE</c> if the call succeeds in boosting the application, <c>FALSE</c> otherwise.
/// <c>SetAdditionalForegroundBoostProcesses</c> sets the last error code, so the application can call GetLastError() to obtain
/// extended information if the call failed (for example, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY, or ERROR_ACCESS_DENIED).
/// </returns>
/// <remarks>
/// <para>
/// This function takes a group of process handles that all get foreground boosted or de-boosted when the passed-in top level HWND
/// moves to the foreground or background respectively. Whenever the passed-in top level HWND becomes the foreground window, a
/// foreground boost will also be applied to the processes passed in the handle array. A similar de-boost happens when the top level
/// HWND moves to the background.
/// </para>
/// <para>
/// The top level HWND passed to this function must be owned by the calling process. The calling process should have the
/// <c>PROCESS_SET_INFORMATION</c> access right on the process handles in the <c>processHandleArray</c> - in other words, you must
/// have full control of every window in your process. If some external component injects a window that takes foreground, or if a
/// dialog box appears, then you lose your boost.
/// </para>
/// <para>If you have two top level windows, you need to call this function for each one.</para>
/// <para>
/// If the passed-in top level HWND is already in the foreground when <c>SetAdditionalForegroundBoostProcesses</c> is called, all of
/// the processes in the <c>processHandleArray</c> are immediately boosted.
/// </para>
/// <para>
/// A process whose handle is in the <c>processHandleArray</c> will get a foreground boost only when the top level HWND becomes the
/// foreground window.
/// </para>
/// <para>Additional foreground boost is applied only when:</para>
/// <list type="number">
/// <item>
/// <term>The foreground window changes, or</term>
/// </item>
/// <item>
/// <term>
/// If this function is called while the window is in the foreground and the new list has the process handle, or the list does not
/// include the process handle while it was previously included.
/// </term>
/// </item>
/// </list>
/// <para>
/// When the process owning the top level HWND exits or terminates, the additional boosting relationship is torn down and secondary
/// processes do not receive any additional foreground boosting.
/// </para>
/// <para>
/// The primary process's top level HWND will continue to hold references to secondary processes until either the primary process's
/// top level HWND clears its grouped boost state, or the HWND is destroyed.
/// </para>
/// </remarks>
/// <example>
/// <para>
/// In this simple scenario, the application sets up its foreground process boost configuration when the top level window is created.
/// When WM_CREATE is handled, the function is called with handles in the lParam and the count of handles in the wParam. These
/// processes will get foreground or background priority boosted as m_AppWindow moves in and out of being the foreground window. If
/// the m_AppWindow is the foreground window when the function is called, the processes will also get an immediate foreground
/// priority boost.
/// </para>
/// <code language="cpp"><![CDATA[case WM_CREATE:
///
/// //
/// // Configure the passed in worker processes (handles) in lParam, to get foreground priority boost when m_AppWindow moves in and
/// // out of the foreground.
/// //
///
/// HANDLE* pMyHandles = retinterpret_cast<HANDLE*>(lParam);
/// DWORD cHandles = reinterpret_cast<DWORD>(wParam);
///
/// if (!SetAdditionalForegroundBoostProcesses(m_AppWindow, cHandles, pMyHandles))
/// {
/// printf(“SetAdditionalForegroundBoostProcesses() setup failed with error code: % d\n”, GetLastError());
/// }
///
/// break;]]></code>
/// </example>
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setadditionalforegroundboostprocesses
// BOOL SetAdditionalForegroundBoostProcesses( HWND topLevelWindow, DWORD processHandleCount, HANDLE *processHandleArray );
[PInvokeData("Winuser.h", MSDNShortId = "NF:winuser.SetAdditionalForegroundBoostProcesses", MinClient = PInvokeClient.Windows11)]
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetAdditionalForegroundBoostProcesses(HWND topLevelWindow, uint processHandleCount,
[Optional, In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] HPROCESS[] processHandleArray);
/// <summary> /// <summary>
/// <para> /// <para>
/// Sets the mouse capture to the specified window belonging to the current thread. <c>SetCapture</c> captures mouse input either /// Sets the mouse capture to the specified window belonging to the current thread. <c>SetCapture</c> captures mouse input either

View File

@ -47,6 +47,20 @@ namespace Vanara.PInvoke
AR_LAPTOP = 0x80, AR_LAPTOP = 0x80,
} }
/// <summary>Defines constants that indicate whether a window is registered or unregistered to receive tooltip dismiss notifications.</summary>
/// <remarks>This enumeration is used by the RegisterForTooltipDismissNotification function.</remarks>
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/ne-winuser-tooltip_dismiss_flags
// typedef enum { TDF_REGISTER, TDF_UNREGISTER } TOOLTIP_DISMISS_FLAGS;
[PInvokeData("winuser.h", MSDNShortId = "NE:winuser.__unnamed_enum_2")]
public enum TOOLTIP_DISMISS_FLAGS
{
/// <summary>The window is registered to receive tooltip dismiss notifications.</summary>
TDF_REGISTER,
/// <summary>The window is unregistered from receiving tooltip dismiss notifications.</summary>
TDF_UNREGISTER,
}
/// <summary> /// <summary>
/// <para>Translates a string into the OEM-defined character set.</para> /// <para>Translates a string into the OEM-defined character set.</para>
/// <para><c>Warning</c> Do not use. See Security Considerations.</para> /// <para><c>Warning</c> Do not use. See Security Considerations.</para>
@ -196,6 +210,76 @@ namespace Vanara.PInvoke
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
public static extern bool OemToCharBuff(string lpszSrc, StringBuilder lpszDst, uint cchDstLength); public static extern bool OemToCharBuff(string lpszSrc, StringBuilder lpszDst, uint cchDstLength);
/// <summary>Registers or unregisters windows to receive notification to dismiss their tooltip windows.</summary>
/// <param name="hWnd">
/// <para>Type: <c>HWND</c></para>
/// <para>The handle of the window to receive the <c>WM_TOOLTIPDISMISS</c> message.</para>
/// </param>
/// <param name="tdFlags">
/// <para>Type: <c>TOOLTIP_DISMISS_FLAGS</c></para>
/// <para>
/// A value of the enumeration that specifies whether the function registers or unregisters the window. <c>TDF_REGISTER</c> to
/// register; <c>TDF_UNREGISTER</c> to unregister.
/// </para>
/// </param>
/// <returns><c>TRUE</c> if the window was successfully registered or unregistered; otherwise, <c>FALSE</c>. (See Remarks.)</returns>
/// <remarks>
/// <para>
/// This function makes tooltips more accessible by letting apps and frameworks that support tooltips register and unregister to be
/// notified by a <c>WM_TOOLTIPDISMISS</c> message when the system requires all showing tooltips to be dismissed.
/// </para>
/// <para>
/// Apps should register for this notification each time they show a tooltip and hide their tooltips in response to a
/// <c>WM_TOOLTIPDISMISS</c> message. When a tooltip is hidden for some other reason, like a mouse action, the app should unregister.
/// </para>
/// <para>
/// System-defined triggers for tooltip dismissal include a solitary Ctrl key up or Ctrl+Shift+F10. (The set of triggers may change
/// over time.)
/// </para>
/// <para>The function takes either the <c>HWND</c> of a tooltip window or the <c>HWND</c> of an app window that has child tooltips.</para>
/// <list type="bullet">
/// <item>
/// <term>
/// If a tooltip <c>HWND</c> itself is registered, the tooltip window is expected to register upon showing and to dismiss upon
/// receiving a <c>WM_TOOLTIPDISMISS</c> message.
/// </term>
/// </item>
/// <item>
/// <term>
/// If an app <c>HWND</c> registers on behalf of its tooltips, the app's window is expected to register upon showing tooltips and
/// dismiss all of its tooltips upon receiving a <c>WM_TOOLTIPDISMISS</c> message.
/// </term>
/// </item>
/// </list>
/// <para>
/// Tooltip or app windows are expected to call the function to register each time tooltips are shown. Registered windows are
/// automatically unregistered upon posting <c>WM_TOOLTIPDISMISS</c>.
/// </para>
/// <para>
/// The <c>TDF_UNREGISTER</c> flag is used to explicitly unregister a window when a tooltip window is dismissed by application or
/// framework prerogative (such as moving the cursor out of the "safe zone"). If an app or framework calls with <c>TDF_UNREGISTER</c>
/// after the window has been automatically unregistered, the function returns <c>FALSE</c>. There is no impact on future registrations.
/// </para>
/// <para>Return values</para>
/// <para>The HWND passed into the function must be owned by the calling process; otherwise, the function returns <c>FALSE</c>.</para>
/// <para>
/// When called with <c>TDF_REGISTER</c> and a window belonging to the calling process, the function returns <c>TRUE</c> if the
/// window was successfully registered or <c>FALSE</c> if the window was already registered. The window is treated as registered
/// either way.
/// </para>
/// <para>
/// When called with <c>TDF_UNREGISTER</c> and a windows belonging to the calling process, the function returns <c>TRUE</c> if the
/// window is successfully unregistered, or <c>FALSE</c> if the windows was not currently registered. The window is treated as
/// unregistered either way.
/// </para>
/// </remarks>
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerfortooltipdismissnotification?view=vs-2019
// BOOL RegisterForTooltipDismissNotification( HWND hWnd, TOOLTIP_DISMISS_FLAGS tdFlags );
[PInvokeData("winuser.h", MSDNShortId = "NF:winuser.RegisterForTooltipDismissNotification")]
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool RegisterForTooltipDismissNotification(HWND hWnd, TOOLTIP_DISMISS_FLAGS tdFlags);
/// <summary> /// <summary>
/// <para>Sets the last-error code.</para> /// <para>Sets the last-error code.</para>
/// <para>Currently, this function is identical to the SetLastError function. The second parameter is ignored.</para> /// <para>Currently, this function is identical to the SetLastError function. The second parameter is ignored.</para>

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Vanara.Extensions; using Vanara.Extensions;
using Vanara.InteropServices; using Vanara.InteropServices;
@ -7,11 +8,11 @@ using static Vanara.PInvoke.Ws2_32;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME; using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
using INTERNET_PORT = System.UInt16; using INTERNET_PORT = System.UInt16;
namespace Vanara.PInvoke namespace Vanara.PInvoke;
/// <summary>Items from the WinHTTP.dll.</summary>
public static partial class WinHTTP
{ {
/// <summary>Items from the WinHTTP.dll.</summary>
public static partial class WinHTTP
{
/// <summary>Provides a handle to an internet connection.</summary> /// <summary>Provides a handle to an internet connection.</summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct HINTERNET : IHandle public struct HINTERNET : IHandle
@ -51,7 +52,7 @@ namespace Vanara.PInvoke
public static bool operator ==(HINTERNET h1, HINTERNET h2) => h1.handle == h2.handle; public static bool operator ==(HINTERNET h1, HINTERNET h2) => h1.handle == h2.handle;
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => (obj is IHandle h && handle == h.DangerousGetHandle()) || (obj is IntPtr p && handle == p); public override bool Equals(object obj) => obj is IHandle h && handle == h.DangerousGetHandle() || obj is IntPtr p && handle == p;
/// <inheritdoc/> /// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode(); public override int GetHashCode() => handle.GetHashCode();
@ -76,8 +77,8 @@ namespace Vanara.PInvoke
} }
/// <summary> /// <summary>
/// The <c>WINHTTP_ASYNC_RESULT</c> structure contains the result of a call to an asynchronous function. This structure is used with /// The <c>WINHTTP_ASYNC_RESULT</c> structure contains the result of a call to an asynchronous function. This structure is used with the
/// the WINHTTP_STATUS_CALLBACK prototype. /// WINHTTP_STATUS_CALLBACK prototype.
/// </summary> /// </summary>
/// <remarks><c>Note</c> For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHttp start page.</remarks> /// <remarks><c>Note</c> For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHttp start page.</remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_async_result typedef struct _WINHTTP_ASYNC_RESULT { // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_async_result typedef struct _WINHTTP_ASYNC_RESULT {
@ -126,12 +127,12 @@ namespace Vanara.PInvoke
} }
/// <summary> /// <summary>
/// The <c>WINHTTP_AUTOPROXY_OPTIONS</c> structure is used to indicate to the WinHttpGetProxyForURL function whether to specify the /// The <c>WINHTTP_AUTOPROXY_OPTIONS</c> structure is used to indicate to the WinHttpGetProxyForURL function whether to specify the URL
/// URL of the Proxy Auto-Configuration (PAC) file or to automatically locate the URL with DHCP or DNS queries to the network. /// of the Proxy Auto-Configuration (PAC) file or to automatically locate the URL with DHCP or DNS queries to the network.
/// </summary> /// </summary>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_autoproxy_options typedef struct // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_autoproxy_options typedef struct
// _WINHTTP_AUTOPROXY_OPTIONS { DWORD dwFlags; DWORD dwAutoDetectFlags; LPCWSTR lpszAutoConfigUrl; LPVOID lpvReserved; DWORD // _WINHTTP_AUTOPROXY_OPTIONS { DWORD dwFlags; DWORD dwAutoDetectFlags; LPCWSTR lpszAutoConfigUrl; LPVOID lpvReserved; DWORD dwReserved;
// dwReserved; BOOL fAutoLogonIfChallenged; } WINHTTP_AUTOPROXY_OPTIONS, *PWINHTTP_AUTOPROXY_OPTIONS; // BOOL fAutoLogonIfChallenged; } WINHTTP_AUTOPROXY_OPTIONS, *PWINHTTP_AUTOPROXY_OPTIONS;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_AUTOPROXY_OPTIONS")] [PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_AUTOPROXY_OPTIONS")]
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct WINHTTP_AUTOPROXY_OPTIONS public struct WINHTTP_AUTOPROXY_OPTIONS
@ -187,9 +188,8 @@ namespace Vanara.PInvoke
/// <item> /// <item>
/// <term><c>WINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY</c></term> /// <term><c>WINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY</c></term>
/// <term> /// <term>
/// By default, WinHTTP is configured to fall back to auto-discover a proxy in-process. If this fallback behavior is undesirable /// By default, WinHTTP is configured to fall back to auto-discover a proxy in-process. If this fallback behavior is undesirable in
/// in the event that an out-of-process discovery fails, it can be disabled using this flag. This option has no effect when /// the event that an out-of-process discovery fails, it can be disabled using this flag. This option has no effect when passed to WinHttpGetProxyForUrlEx.
/// passed to WinHttpGetProxyForUrlEx.
/// </term> /// </term>
/// </item> /// </item>
/// <item> /// <item>
@ -202,9 +202,9 @@ namespace Vanara.PInvoke
/// <summary> /// <summary>
/// <para> /// <para>
/// If <c>dwFlags</c> includes the WINHTTP_AUTOPROXY_AUTO_DETECT flag, then <c>dwAutoDetectFlags</c> specifies what protocols are /// If <c>dwFlags</c> includes the WINHTTP_AUTOPROXY_AUTO_DETECT flag, then <c>dwAutoDetectFlags</c> specifies what protocols are to
/// to be used to locate the PAC file. If both the DHCP and DNS auto detect flags are specified, then DHCP is used first; if no /// be used to locate the PAC file. If both the DHCP and DNS auto detect flags are specified, then DHCP is used first; if no PAC URL
/// PAC URL is discovered using DHCP, then DNS is used. /// is discovered using DHCP, then DNS is used.
/// </para> /// </para>
/// <para>If <c>dwFlags</c> does not include the WINHTTP_AUTOPROXY_AUTO_DETECT flag, then <c>dwAutoDetectFlags</c> must be zero.</para> /// <para>If <c>dwFlags</c> does not include the WINHTTP_AUTOPROXY_AUTO_DETECT flag, then <c>dwAutoDetectFlags</c> must be zero.</para>
/// <list type="table"> /// <list type="table">
@ -218,9 +218,7 @@ namespace Vanara.PInvoke
/// </item> /// </item>
/// <item> /// <item>
/// <term><c>WINHTTP_AUTO_DETECT_TYPE_DNS_A</c></term> /// <term><c>WINHTTP_AUTO_DETECT_TYPE_DNS_A</c></term>
/// <term> /// <term>Use DNS to attempt to locate the proxy auto-configuration file at a well-known location on the domain of the local computer.</term>
/// Use DNS to attempt to locate the proxy auto-configuration file at a well-known location on the domain of the local computer.
/// </term>
/// </item> /// </item>
/// </list> /// </list>
/// </summary> /// </summary>
@ -244,12 +242,12 @@ namespace Vanara.PInvoke
/// <summary> /// <summary>
/// <para> /// <para>
/// Specifies whether the client's domain credentials should be automatically sent in response to an NTLM or Negotiate /// Specifies whether the client's domain credentials should be automatically sent in response to an NTLM or Negotiate Authentication
/// Authentication challenge when WinHTTP requests the PAC file. /// challenge when WinHTTP requests the PAC file.
/// </para> /// </para>
/// <para> /// <para>
/// If this flag is TRUE, credentials should automatically be sent in response to an authentication challenge. If this flag is /// If this flag is TRUE, credentials should automatically be sent in response to an authentication challenge. If this flag is FALSE
/// FALSE and authentication is required to download the PAC file, the WinHttpGetProxyForUrl function fails. /// and authentication is required to download the PAC file, the WinHttpGetProxyForUrl function fails.
/// </para> /// </para>
/// </summary> /// </summary>
[MarshalAs(UnmanagedType.Bool)] [MarshalAs(UnmanagedType.Bool)]
@ -257,24 +255,24 @@ namespace Vanara.PInvoke
} }
/// <summary> /// <summary>
/// The <c>WINHTTP_CERTIFICATE_INFO</c> structure contains certificate information returned from the server. This structure is used /// The <c>WINHTTP_CERTIFICATE_INFO</c> structure contains certificate information returned from the server. This structure is used by
/// by the WinHttpQueryOption function. /// the WinHttpQueryOption function.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// The <c>WINHTTP_CERTIFICATE_INFO</c> structure contains information on the certificate returned by the server when the connection /// The <c>WINHTTP_CERTIFICATE_INFO</c> structure contains information on the certificate returned by the server when the connection uses
/// uses SSL/TLS. The WinHttpQueryOption function returns the <c>WINHTTP_CERTIFICATE_INFO</c> structure when the <c>dwOption</c> /// SSL/TLS. The WinHttpQueryOption function returns the <c>WINHTTP_CERTIFICATE_INFO</c> structure when the <c>dwOption</c> parameter
/// parameter passed to the <c>WinHttpQueryOption</c> function is set to <c>WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT</c>. For more /// passed to the <c>WinHttpQueryOption</c> function is set to <c>WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT</c>. For more information,
/// information, see Option Flags. /// see Option Flags.
/// </para> /// </para>
/// <para> /// <para>
/// The WinHttpQueryOption function does not set the <c>lpszProtocolName</c>, <c>lpszSignatureAlgName</c>, and /// The WinHttpQueryOption function does not set the <c>lpszProtocolName</c>, <c>lpszSignatureAlgName</c>, and
/// <c>lpszEncryptionAlgName</c> members of the <c>WINHTTP_CERTIFICATE_INFO</c> structure, so these member are always returned as <c>NULL</c>. /// <c>lpszEncryptionAlgName</c> members of the <c>WINHTTP_CERTIFICATE_INFO</c> structure, so these member are always returned as <c>NULL</c>.
/// </para> /// </para>
/// <para> /// <para>
/// Once the application no longer needs the returned <c>WINHTTP_CERTIFICATE_INFO</c> structure, the LocalFree function should be /// Once the application no longer needs the returned <c>WINHTTP_CERTIFICATE_INFO</c> structure, the LocalFree function should be called
/// called to free any pointers returned in the structure. The structure members containing pointers that are not NULL and need to be /// to free any pointers returned in the structure. The structure members containing pointers that are not NULL and need to be freed are
/// freed are <c>lpszSubjectInfo</c> and <c>lpszIssuerInfo</c>. /// <c>lpszSubjectInfo</c> and <c>lpszIssuerInfo</c>.
/// </para> /// </para>
/// <para> /// <para>
/// <note type="note">For Windows XP and Windows 2000, see the Run-Time Requirements section of the Windows HTTP Services start page.</note> /// <note type="note">For Windows XP and Windows 2000, see the Run-Time Requirements section of the Windows HTTP Services start page.</note>
@ -304,8 +302,7 @@ namespace Vanara.PInvoke
public string lpszIssuerInfo; public string lpszIssuerInfo;
/// <summary> /// <summary>
/// A pointer to a buffer that contains the name of the protocol used to provide the secure connection. This member is not /// A pointer to a buffer that contains the name of the protocol used to provide the secure connection. This member is not current used.
/// current used.
/// </summary> /// </summary>
[MarshalAs(UnmanagedType.LPWStr)] [MarshalAs(UnmanagedType.LPWStr)]
public string lpszProtocolName; public string lpszProtocolName;
@ -352,9 +349,9 @@ namespace Vanara.PInvoke
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// When WinHttpReceiveResponse returns, the application can retrieve the source and destination IP address of the request that /// When WinHttpReceiveResponse returns, the application can retrieve the source and destination IP address of the request that generated
/// generated the response. The application calls WinHttpQueryOption with the <c>WINHTTP_OPTION_CONNECTION_INFO</c> option, and /// the response. The application calls WinHttpQueryOption with the <c>WINHTTP_OPTION_CONNECTION_INFO</c> option, and provides the
/// provides the <c>WINHTTP_CONNECTION_INFO</c> structure in the <c>lpBuffer</c> parameter. /// <c>WINHTTP_CONNECTION_INFO</c> structure in the <c>lpBuffer</c> parameter.
/// </para> /// </para>
/// <para>Examples</para> /// <para>Examples</para>
/// <para> /// <para>
@ -362,15 +359,15 @@ namespace Vanara.PInvoke
/// <c>WINHTTP_OPTION_CONNECTION_INFO</c> option. /// <c>WINHTTP_OPTION_CONNECTION_INFO</c> option.
/// </para> /// </para>
/// <para> /// <para>
/// If the original request was redirected, the <c>WINHTTP_CONNECTION_INFO</c> structure contains the IP address and port of the /// If the original request was redirected, the <c>WINHTTP_CONNECTION_INFO</c> structure contains the IP address and port of the request
/// request that resulted from the first non-30X response. /// that resulted from the first non-30X response.
/// </para> /// </para>
/// <para> /// <para>
/// <code>WINHTTP_CONNECTION_INFO ConnInfo; DWORD dwConnInfoSize = sizeof(WINHTTP_CONNECTION_INFO); WinHttpQueryOption( hRequest, WINHTTP_OPTION_CONNECTION_INFO, &amp;ConnInfo, &amp;dwConnInfoSize);</code> /// <code>WINHTTP_CONNECTION_INFO ConnInfo; DWORD dwConnInfoSize = sizeof(WINHTTP_CONNECTION_INFO); WinHttpQueryOption( hRequest, WINHTTP_OPTION_CONNECTION_INFO, &amp;ConnInfo, &amp;dwConnInfoSize);</code>
/// </para> /// </para>
/// </remarks> /// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_connection_info typedef struct // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_connection_info typedef struct _WINHTTP_CONNECTION_INFO
// _WINHTTP_CONNECTION_INFO { DWORD cbSize; SOCKADDR_STORAGE LocalAddress; SOCKADDR_STORAGE RemoteAddress; } WINHTTP_CONNECTION_INFO, *PWINHTTP_CONNECTION_INFO; // { DWORD cbSize; SOCKADDR_STORAGE LocalAddress; SOCKADDR_STORAGE RemoteAddress; } WINHTTP_CONNECTION_INFO, *PWINHTTP_CONNECTION_INFO;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_CONNECTION_INFO")] [PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_CONNECTION_INFO")]
[StructLayout(LayoutKind.Sequential, Pack = 4)] [StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct WINHTTP_CONNECTION_INFO public struct WINHTTP_CONNECTION_INFO
@ -396,9 +393,9 @@ namespace Vanara.PInvoke
/// Settings!ShareCredsWithWinHttp</c>. This registry key is not present by default. /// Settings!ShareCredsWithWinHttp</c>. This registry key is not present by default.
/// </para> /// </para>
/// <para> /// <para>
/// When it is set, WinINet will send credentials down to WinHTTP. Whenever WinHttp gets an authentication challenge and if there are /// When it is set, WinINet will send credentials down to WinHTTP. Whenever WinHttp gets an authentication challenge and if there are no
/// no credentials set on the current handle, it will use the credentials provided by WinINet. In order to share server credentials /// credentials set on the current handle, it will use the credentials provided by WinINet. In order to share server credentials in
/// in addition to proxy credentials, users needs to set the <c>WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS</c> option flag. /// addition to proxy credentials, users needs to set the <c>WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS</c> option flag.
/// </para> /// </para>
/// </remarks> /// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_creds typedef struct tagWINHTTP_CREDS { LPSTR // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_creds typedef struct tagWINHTTP_CREDS { LPSTR
@ -462,9 +459,9 @@ namespace Vanara.PInvoke
/// Settings\ShareCredsWithWinHttp</c>. This registry key is not present by default. /// Settings\ShareCredsWithWinHttp</c>. This registry key is not present by default.
/// </para> /// </para>
/// <para> /// <para>
/// When it is set, WinINet will send credentials down to WinHTTP. Whenever WinHttp gets an authentication challenge and if there are /// When it is set, WinINet will send credentials down to WinHTTP. Whenever WinHttp gets an authentication challenge and if there are no
/// no credentials set on the current handle, it will use the credentials provided by WinINet. In order to share server credentials /// credentials set on the current handle, it will use the credentials provided by WinINet. In order to share server credentials in
/// in addition to proxy credentials, users needs to set the <c>WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS</c> option flag. /// addition to proxy credentials, users needs to set the <c>WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS</c> option flag.
/// </para> /// </para>
/// </remarks> /// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_creds_ex typedef struct tagWINHTTP_CREDS_EX { LPSTR // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_creds_ex typedef struct tagWINHTTP_CREDS_EX { LPSTR
@ -540,8 +537,8 @@ namespace Vanara.PInvoke
public bool fAutoDetect; public bool fAutoDetect;
/// <summary> /// <summary>
/// Pointer to a null-terminated Unicode string that contains the auto-configuration URL if the Internet Explorer proxy /// Pointer to a null-terminated Unicode string that contains the auto-configuration URL if the Internet Explorer proxy configuration
/// configuration for the current user specifies "Use automatic proxy configuration". /// for the current user specifies "Use automatic proxy configuration".
/// </summary> /// </summary>
public StrPtrUni lpszAutoConfigUrl; public StrPtrUni lpszAutoConfigUrl;
@ -565,9 +562,8 @@ namespace Vanara.PInvoke
} }
/// <summary>Represents an HTTP request header as a name/value string pair.</summary> /// <summary>Represents an HTTP request header as a name/value string pair.</summary>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_extended_header typedef struct // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_extended_header typedef struct _WINHTTP_EXTENDED_HEADER
// _WINHTTP_EXTENDED_HEADER { union { PCWSTR pwszName; PCSTR pszName; }; union { PCWSTR pwszValue; PCSTR pszValue; }; } // { union { PCWSTR pwszName; PCSTR pszName; }; union { PCWSTR pwszValue; PCSTR pszValue; }; } WINHTTP_EXTENDED_HEADER, *PWINHTTP_EXTENDED_HEADER;
// WINHTTP_EXTENDED_HEADER, *PWINHTTP_EXTENDED_HEADER;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_EXTENDED_HEADER")] [PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_EXTENDED_HEADER")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct WINHTTP_EXTENDED_HEADER public struct WINHTTP_EXTENDED_HEADER
@ -596,8 +592,8 @@ namespace Vanara.PInvoke
} }
/// <summary>Represents an HTTP request header name.</summary> /// <summary>Represents an HTTP request header name.</summary>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_header_name typedef union _WINHTTP_HEADER_NAME { // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_header_name typedef union _WINHTTP_HEADER_NAME { PCWSTR
// PCWSTR pwszName; PCSTR pszName; } WINHTTP_HEADER_NAME, *PWINHTTP_HEADER_NAME; // pwszName; PCSTR pszName; } WINHTTP_HEADER_NAME, *PWINHTTP_HEADER_NAME;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_HEADER_NAME")] [PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_HEADER_NAME")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct WINHTTP_HEADER_NAME public struct WINHTTP_HEADER_NAME
@ -638,8 +634,7 @@ namespace Vanara.PInvoke
} }
/// <summary> /// <summary>
/// See the option flag <c>WINHTTP_OPTION_MATCH_CONNECTION_GUID</c>. That option takes as input a /// See the option flag <c>WINHTTP_OPTION_MATCH_CONNECTION_GUID</c>. That option takes as input a <c>WINHTTP_MATCH_CONNECTION_GUID</c> value.
/// <c>WINHTTP_MATCH_CONNECTION_GUID</c> value.
/// </summary> /// </summary>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_match_connection_guid typedef struct // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_match_connection_guid typedef struct
// _WINHTTP_MATCH_CONNECTION_GUID { GUID ConnectionGuid; ULONGLONG ullFlags; } WINHTTP_MATCH_CONNECTION_GUID, *PWINHTTP_MATCH_CONNECTION_GUID; // _WINHTTP_MATCH_CONNECTION_GUID { GUID ConnectionGuid; ULONGLONG ullFlags; } WINHTTP_MATCH_CONNECTION_GUID, *PWINHTTP_MATCH_CONNECTION_GUID;
@ -661,21 +656,75 @@ namespace Vanara.PInvoke
/// <para>Type: <c>ULONGLONG</c></para> /// <para>Type: <c>ULONGLONG</c></para>
/// <para>Flags.</para> /// <para>Flags.</para>
/// <para> /// <para>
/// Due to the nature of connection-matching logic, it's possible for an unmarked connection to be assigned to serve the request /// Due to the nature of connection-matching logic, it's possible for an unmarked connection to be assigned to serve the request (if
/// (if one is encountered before a matching marked connection is). Set ullFlags to /// one is encountered before a matching marked connection is). Set ullFlags to
/// <c>WINHTTP_MATCH_CONNECTION_GUID_FLAG_REQUIRE_MARKED_CONNECTION</c> if you don't want an unmarked connection to be matched. /// <c>WINHTTP_MATCH_CONNECTION_GUID_FLAG_REQUIRE_MARKED_CONNECTION</c> if you don't want an unmarked connection to be matched. When
/// When using that flag, if no matching marked connection is found, then a new connection is created, and the request is sent on /// using that flag, if no matching marked connection is found, then a new connection is created, and the request is sent on that connection.
/// that connection.
/// </para> /// </para>
/// </summary> /// </summary>
public WINHTTP_MATCH_CONNECTION_GUID_FLAG ullFlags; public WINHTTP_MATCH_CONNECTION_GUID_FLAG ullFlags;
} }
/// <summary>Provides a handle that identifies the registration of the callback function.</summary>
[StructLayout(LayoutKind.Sequential)]
public struct WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE : IHandle
{
private readonly IntPtr handle;
/// <summary>Initializes a new instance of the <see cref="WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE"/> struct.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
public WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// <summary>
/// Returns an invalid handle by instantiating a <see cref="WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE"/> object with <see cref="IntPtr.Zero"/>.
/// </summary>
public static WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE NULL => new(IntPtr.Zero);
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
public bool IsNull => handle == IntPtr.Zero;
/// <summary>Implements the operator !.</summary>
/// <param name="h1">The handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator !(WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE h1) => h1.IsNull;
/// <summary>Performs an explicit conversion from <see cref="WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE"/> to <see cref="IntPtr"/>.</summary>
/// <param name="h">The handle.</param>
/// <returns>The result of the conversion.</returns>
public static explicit operator IntPtr(WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE h) => h.handle;
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE"/>.</summary>
/// <param name="h">The pointer to a handle.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE(IntPtr h) => new(h);
/// <summary>Implements the operator !=.</summary>
/// <param name="h1">The first handle.</param>
/// <param name="h2">The second handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator !=(WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE h1, WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE h2) => !(h1 == h2);
/// <summary>Implements the operator ==.</summary>
/// <param name="h1">The first handle.</param>
/// <param name="h2">The second handle.</param>
/// <returns>The result of the operator.</returns>
public static bool operator ==(WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE h1, WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE h2) => h1.Equals(h2);
/// <inheritdoc/>
public override bool Equals(object obj) => obj is WINHTTP_PROXY_CHANGE_REGISTRATION_HANDLE h && handle == h.handle;
/// <inheritdoc/>
public override int GetHashCode() => handle.GetHashCode();
/// <inheritdoc/>
public IntPtr DangerousGetHandle() => handle;
}
/// <summary>The <c>WINHTTP_PROXY_INFO</c> structure contains the session or default proxy configuration.</summary> /// <summary>The <c>WINHTTP_PROXY_INFO</c> structure contains the session or default proxy configuration.</summary>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// This structure is used with WinHttpSetOption and WinHttpQueryOption to get or set the proxy configuration for the current session /// This structure is used with WinHttpSetOption and WinHttpQueryOption to get or set the proxy configuration for the current session by
/// by specifying the WINHTTP_OPTION_PROXY flag. /// specifying the WINHTTP_OPTION_PROXY flag.
/// </para> /// </para>
/// <para> /// <para>
/// This structure is used with WinHttpSetDefaultProxyConfiguration and WinHttpGetDefaultProxyConfiguration to get or set the default /// This structure is used with WinHttpSetDefaultProxyConfiguration and WinHttpGetDefaultProxyConfiguration to get or set the default
@ -686,14 +735,14 @@ namespace Vanara.PInvoke
/// <code>([&lt;scheme&gt;=][&lt;scheme&gt;"://"]&lt;server&gt;[":"&lt;port&gt;])</code> /// <code>([&lt;scheme&gt;=][&lt;scheme&gt;"://"]&lt;server&gt;[":"&lt;port&gt;])</code>
/// </para> /// </para>
/// <para> /// <para>
/// The proxy bypass list contains one or more server names separated by semicolons or whitespace. The proxy bypass list can also /// The proxy bypass list contains one or more server names separated by semicolons or whitespace. The proxy bypass list can also contain
/// contain the string "&lt;local&gt;" to indicate that all local intranet sites are bypassed. Local intranet sites are considered to /// the string "&lt;local&gt;" to indicate that all local intranet sites are bypassed. Local intranet sites are considered to be all
/// be all servers that do not contain a period in their name. /// servers that do not contain a period in their name.
/// </para> /// </para>
/// <para><c>Note</c> For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHttp start page.</para> /// <para><c>Note</c> For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHttp start page.</para>
/// </remarks> /// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_proxy_info typedef struct _WINHTTP_PROXY_INFO { // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_proxy_info typedef struct _WINHTTP_PROXY_INFO { DWORD
// DWORD dwAccessType; LPWSTR lpszProxy; LPWSTR lpszProxyBypass; } WINHTTP_PROXY_INFO, *LPWINHTTP_PROXY_INFO, *PWINHTTP_PROXY_INFO; // dwAccessType; LPWSTR lpszProxy; LPWSTR lpszProxyBypass; } WINHTTP_PROXY_INFO, *LPWINHTTP_PROXY_INFO, *PWINHTTP_PROXY_INFO;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_PROXY_INFO")] [PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_PROXY_INFO")]
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct WINHTTP_PROXY_INFO public struct WINHTTP_PROXY_INFO
@ -739,8 +788,8 @@ namespace Vanara.PInvoke
/// <summary>The <c>WINHTTP_PROXY_INFO</c> structure contains the session or default proxy configuration.</summary> /// <summary>The <c>WINHTTP_PROXY_INFO</c> structure contains the session or default proxy configuration.</summary>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// This structure is used with WinHttpSetOption and WinHttpQueryOption to get or set the proxy configuration for the current session /// This structure is used with WinHttpSetOption and WinHttpQueryOption to get or set the proxy configuration for the current session by
/// by specifying the WINHTTP_OPTION_PROXY flag. /// specifying the WINHTTP_OPTION_PROXY flag.
/// </para> /// </para>
/// <para> /// <para>
/// This structure is used with WinHttpSetDefaultProxyConfiguration and WinHttpGetDefaultProxyConfiguration to get or set the default /// This structure is used with WinHttpSetDefaultProxyConfiguration and WinHttpGetDefaultProxyConfiguration to get or set the default
@ -751,14 +800,14 @@ namespace Vanara.PInvoke
/// <code>([&lt;scheme&gt;=][&lt;scheme&gt;"://"]&lt;server&gt;[":"&lt;port&gt;])</code> /// <code>([&lt;scheme&gt;=][&lt;scheme&gt;"://"]&lt;server&gt;[":"&lt;port&gt;])</code>
/// </para> /// </para>
/// <para> /// <para>
/// The proxy bypass list contains one or more server names separated by semicolons or whitespace. The proxy bypass list can also /// The proxy bypass list contains one or more server names separated by semicolons or whitespace. The proxy bypass list can also contain
/// contain the string "&lt;local&gt;" to indicate that all local intranet sites are bypassed. Local intranet sites are considered to /// the string "&lt;local&gt;" to indicate that all local intranet sites are bypassed. Local intranet sites are considered to be all
/// be all servers that do not contain a period in their name. /// servers that do not contain a period in their name.
/// </para> /// </para>
/// <para><c>Note</c> For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHttp start page.</para> /// <para><c>Note</c> For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHttp start page.</para>
/// </remarks> /// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_proxy_info typedef struct _WINHTTP_PROXY_INFO { // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_proxy_info typedef struct _WINHTTP_PROXY_INFO { DWORD
// DWORD dwAccessType; LPWSTR lpszProxy; LPWSTR lpszProxyBypass; } WINHTTP_PROXY_INFO, *LPWINHTTP_PROXY_INFO, *PWINHTTP_PROXY_INFO; // dwAccessType; LPWSTR lpszProxy; LPWSTR lpszProxyBypass; } WINHTTP_PROXY_INFO, *LPWINHTTP_PROXY_INFO, *PWINHTTP_PROXY_INFO;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_PROXY_INFO")] [PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_PROXY_INFO")]
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct WINHTTP_PROXY_INFO_IN public struct WINHTTP_PROXY_INFO_IN
@ -795,6 +844,14 @@ namespace Vanara.PInvoke
public string lpszProxyBypass; public string lpszProxyBypass;
} }
/// <summary/>
public struct WINHTTP_PROXY_NETWORKING_KEY
{
/// <summary/>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public byte[] pbBuffer;
}
/// <summary>The <c>WINHTTP_PROXY_RESULT</c> structure contains collection of proxy result entries provided by WinHttpGetProxyResult.</summary> /// <summary>The <c>WINHTTP_PROXY_RESULT</c> structure contains collection of proxy result entries provided by WinHttpGetProxyResult.</summary>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_proxy_result typedef struct _WINHTTP_PROXY_RESULT { // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_proxy_result typedef struct _WINHTTP_PROXY_RESULT {
// DWORD cEntries; WINHTTP_PROXY_RESULT_ENTRY *pEntries; } WINHTTP_PROXY_RESULT; // DWORD cEntries; WINHTTP_PROXY_RESULT_ENTRY *pEntries; } WINHTTP_PROXY_RESULT;
@ -821,15 +878,15 @@ namespace Vanara.PInvoke
public struct WINHTTP_PROXY_RESULT_ENTRY public struct WINHTTP_PROXY_RESULT_ENTRY
{ {
/// <summary> /// <summary>
/// A <c>BOOL</c> that whether a result is from a proxy. It is set to <c>TRUE</c> if the result contains a proxy or <c>FALSE</c> /// A <c>BOOL</c> that whether a result is from a proxy. It is set to <c>TRUE</c> if the result contains a proxy or <c>FALSE</c> if
/// if the result does not contain a proxy. /// the result does not contain a proxy.
/// </summary> /// </summary>
[MarshalAs(UnmanagedType.Bool)] [MarshalAs(UnmanagedType.Bool)]
public bool fProxy; public bool fProxy;
/// <summary> /// <summary>
/// A BOOL that indicates if the result is bypassing a proxy (on an intranet). It is set to <c>TRUE</c> if the result is /// A BOOL that indicates if the result is bypassing a proxy (on an intranet). It is set to <c>TRUE</c> if the result is bypassing a
/// bypassing a proxy or <c>FALSE</c> if all traffic is direct. This parameter applies only if <c>fProxy</c> is <c>FALSE</c>. /// proxy or <c>FALSE</c> if all traffic is direct. This parameter applies only if <c>fProxy</c> is <c>FALSE</c>.
/// </summary> /// </summary>
[MarshalAs(UnmanagedType.Bool)] [MarshalAs(UnmanagedType.Bool)]
public bool fBypass; public bool fBypass;
@ -852,44 +909,213 @@ namespace Vanara.PInvoke
{ {
/// <summary/> /// <summary/>
public uint dwStructSize; public uint dwStructSize;
/// <summary/> /// <summary/>
public uint dwFlags; public uint dwFlags;
/// <summary/> /// <summary/>
public uint dwCurrentSettingsVersion; public uint dwCurrentSettingsVersion;
/// <summary/> /// <summary/>
[MarshalAs(UnmanagedType.LPWStr)] public string pwszConnectionName; [MarshalAs(UnmanagedType.LPWStr)] public string pwszConnectionName;
/// <summary/> /// <summary/>
[MarshalAs(UnmanagedType.LPWStr)] public string pwszProxy; [MarshalAs(UnmanagedType.LPWStr)] public string pwszProxy;
/// <summary/> /// <summary/>
[MarshalAs(UnmanagedType.LPWStr)] public string pwszProxyBypass; [MarshalAs(UnmanagedType.LPWStr)] public string pwszProxyBypass;
/// <summary/> /// <summary/>
[MarshalAs(UnmanagedType.LPWStr)] public string pwszAutoconfigUrl; [MarshalAs(UnmanagedType.LPWStr)] public string pwszAutoconfigUrl;
/// <summary/> /// <summary/>
[MarshalAs(UnmanagedType.LPWStr)] public string pwszAutoconfigSecondaryUrl; [MarshalAs(UnmanagedType.LPWStr)] public string pwszAutoconfigSecondaryUrl;
/// <summary/> /// <summary/>
public uint dwAutoDiscoveryFlags; public uint dwAutoDiscoveryFlags;
/// <summary/> /// <summary/>
[MarshalAs(UnmanagedType.LPWStr)] public string pwszLastKnownGoodAutoConfigUrl; [MarshalAs(UnmanagedType.LPWStr)] public string pwszLastKnownGoodAutoConfigUrl;
/// <summary/> /// <summary/>
public uint dwAutoconfigReloadDelayMins; public uint dwAutoconfigReloadDelayMins;
/// <summary/> /// <summary/>
public FILETIME ftLastKnownDetectTime; public FILETIME ftLastKnownDetectTime;
/// <summary/> /// <summary/>
public uint dwDetectedInterfaceIpCount; public uint dwDetectedInterfaceIpCount;
/// <summary/> /// <summary/>
public IntPtr pdwDetectedInterfaceIp; public IntPtr pdwDetectedInterfaceIp;
/// <summary/> /// <summary/>
public uint cNetworkKeys; public uint cNetworkKeys;
/// <summary/> /// <summary/>
public IntPtr pNetworkKeys; public IntPtr pNetworkKeys;
} }
/// <summary/> /// <summary>Represents extended proxy settings.</summary>
public struct WINHTTP_PROXY_NETWORKING_KEY // https://learn.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_proxy_settings_ex typedef struct
// _WINHTTP_PROXY_SETTINGS_EX { ULONGLONG ullGenerationId; ULONGLONG ullFlags; PCWSTR pcwszAutoconfigUrl; PCWSTR pcwszProxy; PCWSTR
// pcwszSecureProxy; DWORD cProxyBypasses; PCWSTR *rgpcwszProxyBypasses; DWORD dwInterfaceIndex; PCWSTR pcwszConnectionName; }
// WINHTTP_PROXY_SETTINGS_EX, *PWINHTTP_PROXY_SETTINGS_EX;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_PROXY_SETTINGS_EX")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WINHTTP_PROXY_SETTINGS_EX
{ {
/// <summary/> /// <summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] /// <para>Type: <c>ULONGLONG</c></para>
public byte[] pbBuffer; /// <para>The current network generation (incremented each time the configuration is changed).</para>
/// </summary>
public ulong ullGenerationId;
/// <summary>
/// <para>Type: <c>ULONGLONG</c></para>
/// <para>Flags for the proxy settings (for example, <c>WINHTTP_PROXY_TYPE_DIRECT</c>).</para>
/// </summary>
public WINHTTP_PROXY_TYPE ullFlags;
/// <summary>
/// <para>Type: <c>PCWSTR</c></para>
/// <para>The PAC URL for the network (for example, L"http://proxy.contoso.com/wpad.dat").</para>
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
public string pcwszAutoconfigUrl;
/// <summary>
/// <para>Type: <c>PCWSTR</c></para>
/// <para>The proxy address and port for HTTP traffic (for example, L"http://192.168.1.1:8888").</para>
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
public string pcwszProxy;
/// <summary>
/// <para>Type: <c>PCWSTR</c></para>
/// <para>The proxy address and port for HTTPS traffic (for example, L"http://192.168.1.1:8888").</para>
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
public string pcwszSecureProxy;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The number of entries in the proxy bypass list (rgpcwszProxyBypasses).</para>
/// </summary>
public int cProxyBypasses;
private readonly IntPtr _rgpcwszProxyBypasses;
/// <summary>
/// <para>Type: <c>PCWSTR*</c></para>
/// <para>An array of strings containing each site in the proxy bypass list. (for example, L"contoso.com").</para>
/// </summary>
public string[] rgpcwszProxyBypasses => _rgpcwszProxyBypasses.ToStringEnum(cProxyBypasses, CharSet.Unicode).ToArray();
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The interface index for which settings were retrieved.</para>
/// </summary>
public uint dwInterfaceIndex;
/// <summary>
/// <para>Type: <c>PCWSTR</c></para>
/// <para>The WCM connection name for which settings were retrieved.</para>
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
public string pcwszConnectionName;
}
/// <summary>Represents extended proxy settings.</summary>
// https://learn.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_proxy_settings_ex typedef struct
// _WINHTTP_PROXY_SETTINGS_EX { ULONGLONG ullGenerationId; ULONGLONG ullFlags; PCWSTR pcwszAutoconfigUrl; PCWSTR pcwszProxy; PCWSTR
// pcwszSecureProxy; DWORD cProxyBypasses; PCWSTR *rgpcwszProxyBypasses; DWORD dwInterfaceIndex; PCWSTR pcwszConnectionName; }
// WINHTTP_PROXY_SETTINGS_EX, *PWINHTTP_PROXY_SETTINGS_EX;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_PROXY_SETTINGS_EX")]
public struct WINHTTP_PROXY_SETTINGS_EX_MGD
{
/// <summary>
/// <para>Type: <c>ULONGLONG</c></para>
/// <para>The current network generation (incremented each time the configuration is changed).</para>
/// </summary>
public ulong ullGenerationId;
/// <summary>
/// <para>Type: <c>ULONGLONG</c></para>
/// <para>Flags for the proxy settings (for example, <c>WINHTTP_PROXY_TYPE_DIRECT</c>).</para>
/// </summary>
public WINHTTP_PROXY_TYPE ullFlags;
/// <summary>
/// <para>Type: <c>PCWSTR</c></para>
/// <para>The PAC URL for the network (for example, L"http://proxy.contoso.com/wpad.dat").</para>
/// </summary>
public string pcwszAutoconfigUrl;
/// <summary>
/// <para>Type: <c>PCWSTR</c></para>
/// <para>The proxy address and port for HTTP traffic (for example, L"http://192.168.1.1:8888").</para>
/// </summary>
public string pcwszProxy;
/// <summary>
/// <para>Type: <c>PCWSTR</c></para>
/// <para>The proxy address and port for HTTPS traffic (for example, L"http://192.168.1.1:8888").</para>
/// </summary>
public string pcwszSecureProxy;
/// <summary>
/// <para>Type: <c>PCWSTR*</c></para>
/// <para>An array of strings containing each site in the proxy bypass list. (for example, L"contoso.com").</para>
/// </summary>
public string[] rgpcwszProxyBypasses;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The interface index for which settings were retrieved.</para>
/// </summary>
public uint dwInterfaceIndex;
/// <summary>
/// <para>Type: <c>PCWSTR</c></para>
/// <para>The WCM connection name for which settings were retrieved.</para>
/// </summary>
public string pcwszConnectionName;
/// <summary>Performs an implicit conversion from <see cref="WINHTTP_PROXY_SETTINGS_EX"/> to <see cref="WINHTTP_PROXY_SETTINGS_EX_MGD"/>.</summary>
/// <param name="s">The WINHTTP_PROXY_SETTINGS_EX instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator WINHTTP_PROXY_SETTINGS_EX_MGD(in WINHTTP_PROXY_SETTINGS_EX s) =>
new() { ullGenerationId = s.ullGenerationId, ullFlags = s.ullFlags, pcwszAutoconfigUrl = s.pcwszAutoconfigUrl, pcwszProxy = s.pcwszProxy,
pcwszSecureProxy = s.pcwszSecureProxy, rgpcwszProxyBypasses = s.rgpcwszProxyBypasses, dwInterfaceIndex = s.dwInterfaceIndex, pcwszConnectionName = s.pcwszConnectionName };
}
/// <summary>Represents extended proxy settings.</summary>
// https://learn.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_proxy_settings_param typedef struct
// _WINHTTP_PROXY_SETTINGS_PARAM { ULONGLONG ullFlags; PCWSTR pcwszConnectionName; PCWSTR pcwszProbeHost; } WINHTTP_PROXY_SETTINGS_PARAM, *PWINHTTP_PROXY_SETTINGS_PARAM;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_PROXY_SETTINGS_PARAM")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WINHTTP_PROXY_SETTINGS_PARAM
{
/// <summary>
/// <para>Type: <c>ULONGLONG</c></para>
/// <para>Flags.</para>
/// </summary>
public ulong ullFlags;
/// <summary>
/// <para>Type: <c>PCWSTR</c></para>
/// <para>The WCM connection name for which settings were retrieved.</para>
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
public string pcwszConnectionName;
/// <summary>
/// <para>Type: <c>PCWSTR</c></para>
/// <para>TBD</para>
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
public string pcwszProbeHost;
} }
/// <summary>Represents a description of the current state of WinHttp's connections. Retrieved via WinHttpQueryConnectionGroup.</summary> /// <summary>Represents a description of the current state of WinHttp's connections. Retrieved via WinHttpQueryConnectionGroup.</summary>
@ -912,9 +1138,7 @@ namespace Vanara.PInvoke
/// </summary> /// </summary>
public IntPtr pHostConnectionGroups; public IntPtr pHostConnectionGroups;
/// <summary> /// <summary>Gets a list of WINHTTP_HOST_CONNECTION_GROUP objects.</summary>
/// Gets a list of WINHTTP_HOST_CONNECTION_GROUP objects.
/// </summary>
public ReadOnlySpan<WINHTTP_HOST_CONNECTION_GROUP> HostConnectionGroups => pHostConnectionGroups.AsReadOnlySpan<WINHTTP_HOST_CONNECTION_GROUP>((int)cHosts); public ReadOnlySpan<WINHTTP_HOST_CONNECTION_GROUP> HostConnectionGroups => pHostConnectionGroups.AsReadOnlySpan<WINHTTP_HOST_CONNECTION_GROUP>((int)cHosts);
} }
@ -923,8 +1147,8 @@ namespace Vanara.PInvoke
/// This structure is used with WinHttpQueryOption to retrieve statistics for a request by specifying the /// This structure is used with WinHttpQueryOption to retrieve statistics for a request by specifying the
/// <c>WINHTTP_OPTION_REQUEST_STATS</c> flag. /// <c>WINHTTP_OPTION_REQUEST_STATS</c> flag.
/// </remarks> /// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_request_stats typedef struct _WINHTTP_REQUEST_STATS // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_request_stats typedef struct _WINHTTP_REQUEST_STATS {
// { ULONGLONG ullFlags; ULONG ulIndex; ULONG cStats; ULONGLONG rgullStats[WinHttpRequestStatMax]; } WINHTTP_REQUEST_STATS, *PWINHTTP_REQUEST_STATS; // ULONGLONG ullFlags; ULONG ulIndex; ULONG cStats; ULONGLONG rgullStats[WinHttpRequestStatMax]; } WINHTTP_REQUEST_STATS, *PWINHTTP_REQUEST_STATS;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_REQUEST_STATS")] [PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_REQUEST_STATS")]
[StructLayout(LayoutKind.Sequential, Pack = 4)] [StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct WINHTTP_REQUEST_STATS public struct WINHTTP_REQUEST_STATS
@ -964,14 +1188,10 @@ namespace Vanara.PInvoke
/// </summary> /// </summary>
public WINHTTP_REQUEST_STAT_FLAG ullFlags; public WINHTTP_REQUEST_STAT_FLAG ullFlags;
/// <summary> /// <summary>The index of the request on the connection. This indicates how many prior requests were sent over the shared connection.</summary>
/// The index of the request on the connection. This indicates how many prior requests were sent over the shared connection.
/// </summary>
public uint ulIndex; public uint ulIndex;
/// <summary> /// <summary>Unsigned long integer value that contains the number of statistics to retrieve. This should generally be set to <c>WinHttpRequestStatLast</c>.</summary>
/// Unsigned long integer value that contains the number of statistics to retrieve. This should generally be set to <c>WinHttpRequestStatLast</c>.
/// </summary>
public uint cStats; public uint cStats;
/// <summary>Array of unsigned long long integer values that will contain the returned statistics, indexed by <c>WINHTTP_REQUEST_STAT_ENTRY</c>.</summary> /// <summary>Array of unsigned long long integer values that will contain the returned statistics, indexed by <c>WINHTTP_REQUEST_STAT_ENTRY</c>.</summary>
@ -984,15 +1204,13 @@ namespace Vanara.PInvoke
/// This structure is used with WinHttpQueryOption to retrieve timing information for a request by specifying the /// This structure is used with WinHttpQueryOption to retrieve timing information for a request by specifying the
/// <c>WINHTTP_OPTION_REQUEST_TIMES</c> flag. /// <c>WINHTTP_OPTION_REQUEST_TIMES</c> flag.
/// </remarks> /// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_request_times typedef struct _WINHTTP_REQUEST_TIMES // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_request_times typedef struct _WINHTTP_REQUEST_TIMES {
// { ULONG cTimes; ULONGLONG rgullTimes[WinHttpRequestTimeMax]; } WINHTTP_REQUEST_TIMES, *PWINHTTP_REQUEST_TIMES; // ULONG cTimes; ULONGLONG rgullTimes[WinHttpRequestTimeMax]; } WINHTTP_REQUEST_TIMES, *PWINHTTP_REQUEST_TIMES;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_REQUEST_TIMES")] [PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_REQUEST_TIMES")]
[StructLayout(LayoutKind.Sequential, Pack = 4)] [StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct WINHTTP_REQUEST_TIMES public struct WINHTTP_REQUEST_TIMES
{ {
/// <summary> /// <summary>Unsigned long integer value that contains the number of timings to retrieve. This should generally be set to <c>WinHttpRequestTimeLast</c>.</summary>
/// Unsigned long integer value that contains the number of timings to retrieve. This should generally be set to <c>WinHttpRequestTimeLast</c>.
/// </summary>
public uint cTimes; public uint cTimes;
/// <summary> /// <summary>
@ -1008,8 +1226,8 @@ namespace Vanara.PInvoke
/// This structure is used with <c>WinHttpQueryOption</c> to retrieve security information for a request by specifying the /// This structure is used with <c>WinHttpQueryOption</c> to retrieve security information for a request by specifying the
/// <c>WINHTTP_OPTION_SECURITY_INFO</c> flag. /// <c>WINHTTP_OPTION_SECURITY_INFO</c> flag.
/// </remarks> /// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_security_info typedef struct _WINHTTP_SECURITY_INFO // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_security_info typedef struct _WINHTTP_SECURITY_INFO {
// { SecPkgContext_ConnectionInfo ConnectionInfo; SecPkgContext_CipherInfo CipherInfo; } WINHTTP_SECURITY_INFO, *PWINHTTP_SECURITY_INFO; // SecPkgContext_ConnectionInfo ConnectionInfo; SecPkgContext_CipherInfo CipherInfo; } WINHTTP_SECURITY_INFO, *PWINHTTP_SECURITY_INFO;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_SECURITY_INFO")] [PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_SECURITY_INFO")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WINHTTP_SECURITY_INFO public struct WINHTTP_SECURITY_INFO
@ -1027,20 +1245,20 @@ namespace Vanara.PInvoke
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// For the WinHttpCrackUrl function, if a pointer member and its corresponding length member are both zero, that component of the /// For the WinHttpCrackUrl function, if a pointer member and its corresponding length member are both zero, that component of the URL is
/// URL is not returned. If the pointer member is <c>NULL</c> but the length member is not zero, both the pointer and length members /// not returned. If the pointer member is <c>NULL</c> but the length member is not zero, both the pointer and length members are
/// are returned. If both pointer and corresponding length members are nonzero, the pointer member points to a buffer where the /// returned. If both pointer and corresponding length members are nonzero, the pointer member points to a buffer where the component is
/// component is copied. All escape sequences can be removed from a component, depending on the <c>dwFlags</c> parameter of WinHttpCrackUrl. /// copied. All escape sequences can be removed from a component, depending on the <c>dwFlags</c> parameter of WinHttpCrackUrl.
/// </para> /// </para>
/// <para> /// <para>
/// For the WinHttpCreateUrl function, the pointer members should be <c>NULL</c> if the component of the URL is not required. If the /// For the WinHttpCreateUrl function, the pointer members should be <c>NULL</c> if the component of the URL is not required. If the
/// corresponding length member is zero, the pointer member is the pointer to a zero-terminated string. If the length member is not /// corresponding length member is zero, the pointer member is the pointer to a zero-terminated string. If the length member is not zero,
/// zero, it is the string length of the corresponding pointer member. /// it is the string length of the corresponding pointer member.
/// </para> /// </para>
/// <para><c>Note</c> For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHttp start page.</para> /// <para><c>Note</c> For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHttp start page.</para>
/// </remarks> /// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-url_components typedef struct _WINHTTP_URL_COMPONENTS { // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-url_components typedef struct _WINHTTP_URL_COMPONENTS { DWORD
// DWORD dwStructSize; LPWSTR lpszScheme; DWORD dwSchemeLength; INTERNET_SCHEME nScheme; LPWSTR lpszHostName; DWORD dwHostNameLength; // dwStructSize; LPWSTR lpszScheme; DWORD dwSchemeLength; INTERNET_SCHEME nScheme; LPWSTR lpszHostName; DWORD dwHostNameLength;
// INTERNET_PORT nPort; LPWSTR lpszUserName; DWORD dwUserNameLength; LPWSTR lpszPassword; DWORD dwPasswordLength; LPWSTR lpszUrlPath; // INTERNET_PORT nPort; LPWSTR lpszUserName; DWORD dwUserNameLength; LPWSTR lpszPassword; DWORD dwPasswordLength; LPWSTR lpszUrlPath;
// DWORD dwUrlPathLength; LPWSTR lpszExtraInfo; DWORD dwExtraInfoLength; } URL_COMPONENTS, *LPURL_COMPONENTS; // DWORD dwUrlPathLength; LPWSTR lpszExtraInfo; DWORD dwExtraInfoLength; } URL_COMPONENTS, *LPURL_COMPONENTS;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_URL_COMPONENTS")] [PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_URL_COMPONENTS")]
@ -1048,8 +1266,7 @@ namespace Vanara.PInvoke
public struct WINHTTP_URL_COMPONENTS public struct WINHTTP_URL_COMPONENTS
{ {
/// <summary> /// <summary>
/// Size of this structure, in bytes. Used for version checking. The size of this structure must be set to initialize this /// Size of this structure, in bytes. Used for version checking. The size of this structure must be set to initialize this structure properly.
/// structure properly.
/// </summary> /// </summary>
public uint dwStructSize; public uint dwStructSize;
@ -1128,20 +1345,20 @@ namespace Vanara.PInvoke
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// For the WinHttpCrackUrl function, if a pointer member and its corresponding length member are both zero, that component of the /// For the WinHttpCrackUrl function, if a pointer member and its corresponding length member are both zero, that component of the URL is
/// URL is not returned. If the pointer member is <c>NULL</c> but the length member is not zero, both the pointer and length members /// not returned. If the pointer member is <c>NULL</c> but the length member is not zero, both the pointer and length members are
/// are returned. If both pointer and corresponding length members are nonzero, the pointer member points to a buffer where the /// returned. If both pointer and corresponding length members are nonzero, the pointer member points to a buffer where the component is
/// component is copied. All escape sequences can be removed from a component, depending on the <c>dwFlags</c> parameter of WinHttpCrackUrl. /// copied. All escape sequences can be removed from a component, depending on the <c>dwFlags</c> parameter of WinHttpCrackUrl.
/// </para> /// </para>
/// <para> /// <para>
/// For the WinHttpCreateUrl function, the pointer members should be <c>NULL</c> if the component of the URL is not required. If the /// For the WinHttpCreateUrl function, the pointer members should be <c>NULL</c> if the component of the URL is not required. If the
/// corresponding length member is zero, the pointer member is the pointer to a zero-terminated string. If the length member is not /// corresponding length member is zero, the pointer member is the pointer to a zero-terminated string. If the length member is not zero,
/// zero, it is the string length of the corresponding pointer member. /// it is the string length of the corresponding pointer member.
/// </para> /// </para>
/// <para><c>Note</c> For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHttp start page.</para> /// <para><c>Note</c> For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHttp start page.</para>
/// </remarks> /// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-url_components typedef struct _WINHTTP_URL_COMPONENTS { // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-url_components typedef struct _WINHTTP_URL_COMPONENTS { DWORD
// DWORD dwStructSize; LPWSTR lpszScheme; DWORD dwSchemeLength; INTERNET_SCHEME nScheme; LPWSTR lpszHostName; DWORD dwHostNameLength; // dwStructSize; LPWSTR lpszScheme; DWORD dwSchemeLength; INTERNET_SCHEME nScheme; LPWSTR lpszHostName; DWORD dwHostNameLength;
// INTERNET_PORT nPort; LPWSTR lpszUserName; DWORD dwUserNameLength; LPWSTR lpszPassword; DWORD dwPasswordLength; LPWSTR lpszUrlPath; // INTERNET_PORT nPort; LPWSTR lpszUserName; DWORD dwUserNameLength; LPWSTR lpszPassword; DWORD dwPasswordLength; LPWSTR lpszUrlPath;
// DWORD dwUrlPathLength; LPWSTR lpszExtraInfo; DWORD dwExtraInfoLength; } URL_COMPONENTS, *LPURL_COMPONENTS; // DWORD dwUrlPathLength; LPWSTR lpszExtraInfo; DWORD dwExtraInfoLength; } URL_COMPONENTS, *LPURL_COMPONENTS;
[PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_URL_COMPONENTS")] [PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_URL_COMPONENTS")]
@ -1149,8 +1366,7 @@ namespace Vanara.PInvoke
public struct WINHTTP_URL_COMPONENTS_IN public struct WINHTTP_URL_COMPONENTS_IN
{ {
/// <summary> /// <summary>
/// Size of this structure, in bytes. Used for version checking. The size of this structure must be set to initialize this /// Size of this structure, in bytes. Used for version checking. The size of this structure must be set to initialize this structure properly.
/// structure properly.
/// </summary> /// </summary>
public uint dwStructSize; public uint dwStructSize;
@ -1313,7 +1529,9 @@ namespace Vanara.PInvoke
{ {
/// <summary>Initializes a new instance of the <see cref="SafeHINTERNET"/> class and assigns an existing handle.</summary> /// <summary>Initializes a new instance of the <see cref="SafeHINTERNET"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param> /// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle"><see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).</param> /// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeHINTERNET(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } public SafeHINTERNET(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// <summary>Initializes a new instance of the <see cref="SafeHINTERNET"/> class.</summary> /// <summary>Initializes a new instance of the <see cref="SafeHINTERNET"/> class.</summary>
@ -1327,5 +1545,4 @@ namespace Vanara.PInvoke
/// <inheritdoc/> /// <inheritdoc/>
protected override bool InternalReleaseHandle() => WinHttpCloseHandle(handle); protected override bool InternalReleaseHandle() => WinHttpCloseHandle(handle);
} }
}
} }

View File

@ -1800,6 +1800,40 @@ namespace Vanara.PInvoke
WINHTTP_PROTOCOL_FLAG_HTTP3 = 0x2, WINHTTP_PROTOCOL_FLAG_HTTP3 = 0x2,
} }
/// <summary>Defines constants that specify proxy settings types for extended proxy settings APIs.</summary>
// https://learn.microsoft.com/en-us/windows/win32/api/winhttp/ne-winhttp-winhttp_proxy_settings_type typedef enum
// _WINHTTP_PROXY_SETTINGS_TYPE { WinHttpProxySettingsTypeUnknown, WinHttpProxySettingsTypeWsl, WinHttpProxySettingsTypeWsa }
// WINHTTP_PROXY_SETTINGS_TYPE, *PWINHTTP_PROXY_SETTINGS_TYPE;
[PInvokeData("winhttp.h", MSDNShortId = "NE:winhttp._WINHTTP_PROXY_SETTINGS_TYPE")]
public enum WINHTTP_PROXY_SETTINGS_TYPE
{
/// <summary>Specifies an unknown type.</summary>
WinHttpProxySettingsTypeUnknown,
/// <summary>Specifies settings for Windows Subsystem for Linux (WSL).</summary>
WinHttpProxySettingsTypeWsl,
/// <summary>Specifies settings for Windows Subsystem for Android (WSA).</summary>
WinHttpProxySettingsTypeWsa,
}
/// <summary></summary>
[Flags]
public enum WINHTTP_PROXY_TYPE : ulong
{
/// <summary>Direct to net</summary>
WINHTTP_PROXY_TYPE_DIRECT = 0x00000001,
/// <summary>Via named proxy</summary>
WINHTTP_PROXY_TYPE_PROXY = 0x00000002,
/// <summary>Autoproxy URL</summary>
WINHTTP_PROXY_TYPE_AUTO_PROXY_URL = 0x00000004,
/// <summary>Use autoproxy detection</summary>
WINHTTP_PROXY_TYPE_AUTO_DETECT = 0x00000008,
}
/// <summary> /// <summary>
/// <para>These attributes and modifiers are used by WinHttpQueryHeaders.</para> /// <para>These attributes and modifiers are used by WinHttpQueryHeaders.</para>
/// <para> /// <para>