// Copyright © 2015 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. namespace VideoBrowser.Controls.CefSharpBrowser.Helpers { using System; using System.ComponentModel; using System.Runtime.InteropServices; /// /// Defines the . /// public class ProxyConfig { #region Constants private const uint InternetOptionProxy = 38; #endregion Constants #region Methods /// /// The GetProxyInformation. /// /// The . public static InternetProxyInfo GetProxyInformation() { var bufferLength = 0; InternetQueryOption(IntPtr.Zero, InternetOptionProxy, IntPtr.Zero, ref bufferLength); var buffer = IntPtr.Zero; try { buffer = Marshal.AllocHGlobal(bufferLength); if (InternetQueryOption(IntPtr.Zero, InternetOptionProxy, buffer, ref bufferLength)) { var ipi = (InternetProxyInfo)Marshal.PtrToStructure(buffer, typeof(InternetProxyInfo)); return ipi; } throw new Win32Exception(); } finally { if (buffer != IntPtr.Zero) { Marshal.FreeHGlobal(buffer); } } } /// /// The InternetQueryOption. /// /// The hInternet. /// The dwOption. /// The lpBuffer. /// The lpdwBufferLength. /// The . [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern bool InternetQueryOption(IntPtr hInternet, uint dwOption, IntPtr lpBuffer, ref int lpdwBufferLength); #endregion Methods } }