diff --git a/PInvoke/WinHTTP/WinHTTP.Funcs2.cs b/PInvoke/WinHTTP/WinHTTP.Funcs2.cs index f702345d..7dee9dd2 100644 --- a/PInvoke/WinHTTP/WinHTTP.Funcs2.cs +++ b/PInvoke/WinHTTP/WinHTTP.Funcs2.cs @@ -1268,7 +1268,7 @@ namespace Vanara.PInvoke // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/nf-winhttp-winhttpsetoption BOOL WinHttpSetOption( [in] HINTERNET // hInternet, [in] DWORD dwOption, [in] LPVOID lpBuffer, [in] DWORD dwBufferLength ); [PInvokeData("winhttp.h", MSDNShortId = "NF:winhttp.WinHttpSetOption")] - public static bool WinHttpSetOption(HINTERNET hInternet, WINHTTP_OPTION dwOption, T value) where T : struct + public static bool WinHttpSetOption(HINTERNET hInternet, WINHTTP_OPTION dwOption, in T value) where T : struct { using var mem = SafeHGlobalHandle.CreateFromStructure(value); return WinHttpSetOption(hInternet, dwOption, mem, mem.Size); diff --git a/PInvoke/WinHTTP/WinHTTP.Structs.cs b/PInvoke/WinHTTP/WinHTTP.Structs.cs index 7c45a2ee..b7c0ed8a 100644 --- a/PInvoke/WinHTTP/WinHTTP.Structs.cs +++ b/PInvoke/WinHTTP/WinHTTP.Structs.cs @@ -736,6 +736,65 @@ namespace Vanara.PInvoke } } + /// The WINHTTP_PROXY_INFO structure contains the session or default proxy configuration. + /// + /// + /// This structure is used with WinHttpSetOption and WinHttpQueryOption to get or set the proxy configuration for the current session + /// by specifying the WINHTTP_OPTION_PROXY flag. + /// + /// + /// This structure is used with WinHttpSetDefaultProxyConfiguration and WinHttpGetDefaultProxyConfiguration to get or set the default + /// proxy configuration in the registry. + /// + /// The proxy server list contains one or more of the following strings separated by semicolons or whitespace. + /// + /// ([<scheme>=][<scheme>"://"]<server>[":"<port>]) + /// + /// + /// The proxy bypass list contains one or more server names separated by semicolons or whitespace. The proxy bypass list can also + /// contain the string "<local>" to indicate that all local intranet sites are bypassed. Local intranet sites are considered to + /// be all servers that do not contain a period in their name. + /// + /// Note For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHttp start page. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/winhttp/ns-winhttp-winhttp_proxy_info typedef struct _WINHTTP_PROXY_INFO { + // DWORD dwAccessType; LPWSTR lpszProxy; LPWSTR lpszProxyBypass; } WINHTTP_PROXY_INFO, *LPWINHTTP_PROXY_INFO, *PWINHTTP_PROXY_INFO; + [PInvokeData("winhttp.h", MSDNShortId = "NS:winhttp._WINHTTP_PROXY_INFO")] + [StructLayout(LayoutKind.Sequential)] + public struct WINHTTP_PROXY_INFO_IN + { + /// + /// Unsigned long integer value that contains the access type. This can be one of the following values: + /// + /// + /// Value + /// Meaning + /// + /// + /// WINHTTP_ACCESS_TYPE_NO_PROXY + /// Internet accessed through a direct connection. + /// + /// + /// WINHTTP_ACCESS_TYPE_DEFAULT_PROXY + /// Applies only when setting proxy information. + /// + /// + /// WINHTTP_ACCESS_TYPE_NAMED_PROXY + /// Internet accessed using a proxy. + /// + /// + /// + public WINHTTP_ACCESS_TYPE dwAccessType; + + /// Pointer to a string value that contains the proxy server list. + [MarshalAs(UnmanagedType.LPWStr)] + public string lpszProxy; + + /// Pointer to a string value that contains the proxy bypass list. + [MarshalAs(UnmanagedType.LPWStr)] + public string lpszProxyBypass; + } + /// The WINHTTP_PROXY_RESULT structure contains collection of proxy result entries provided by WinHttpGetProxyResult. // 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; diff --git a/PInvoke/WinHTTP/WinHTTP.cs b/PInvoke/WinHTTP/WinHTTP.cs index 410bab52..08d4459c 100644 --- a/PInvoke/WinHTTP/WinHTTP.cs +++ b/PInvoke/WinHTTP/WinHTTP.cs @@ -1416,7 +1416,8 @@ namespace Vanara.PInvoke /// structure (if they are non-NULL) using the GlobalFree function. An application can query for the global proxy data (the /// default proxy) by passing a NULL handle. /// - [CorrespondingType(typeof(WINHTTP_PROXY_INFO))] + [CorrespondingType(typeof(WINHTTP_PROXY_INFO), CorrespondingAction.Get)] + [CorrespondingType(typeof(WINHTTP_PROXY_INFO_IN), CorrespondingAction.Set)] WINHTTP_OPTION_PROXY = 38, /// Undocumented. @@ -1432,7 +1433,7 @@ namespace Vanara.PInvoke WINHTTP_OPTION_PROXY_PASSWORD = 0x1003, /// Undocumented. - [CorrespondingType(typeof(uint), CorrespondingAction.Set)] + [CorrespondingType(typeof(WINHTTP_PROXY_RESULT_ENTRY), CorrespondingAction.Set)] WINHTTP_OPTION_PROXY_RESULT_ENTRY = 39, ///