Created
July 26, 2013 23:31
-
-
Save timerickson/6092927 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
namespace ProxySetup | |
{ | |
public abstract class WinHttpProxyWin32 | |
{ | |
/// <summary> | |
/// WINHTTP_PROXY_INFO - structure supplied with WINHTTP_OPTION_PROXY to | |
/// get/set proxy information on a WinHttpOpen() handle | |
/// </summary> | |
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] | |
public struct WINHTTP_PROXY_INFO | |
{ | |
/// <summary> | |
/// see WINHTTP_ACCESS_* types | |
/// </summary> | |
public WINHTTP_ACCESS_TYPES dwAccessType; | |
/// <summary> | |
/// proxy server list | |
/// </summary> | |
public string lpszProxy; | |
/// <summary> | |
/// proxy bypass list | |
/// </summary> | |
public string lpszProxyBypass; | |
} | |
/// <summary> | |
/// WinHttpOpen dwAccessType values (also for WINHTTP_PROXY_INFO::dwAccessType) | |
/// </summary> | |
public enum WINHTTP_ACCESS_TYPES | |
{ | |
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY = 0, | |
WINHTTP_ACCESS_TYPE_NO_PROXY = 1, | |
WINHTTP_ACCESS_TYPE_NAMED_PROXY = 3 | |
} | |
public const string WINHTTP_NO_PROXY_NAME = null; | |
public const string WINHTTP_NO_PROXY_BYPASS = null; | |
[DllImport("winhttp.dll", CharSet = CharSet.Unicode, SetLastError = true)] | |
public static extern bool WinHttpSetDefaultProxyConfiguration(ref WINHTTP_PROXY_INFO info); | |
[DllImport("winhttp.dll", CharSet = CharSet.Unicode, SetLastError = true)] | |
public static extern bool WinHttpGetDefaultProxyConfiguration(ref WINHTTP_PROXY_INFO info); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment