private static bool CallInternetSetOption(InternetPerConnectionOption[] options) { var optionList = new InternetPerConnectionOptionList(); optionList.size = Marshal.SizeOf(optionList); optionList.connection = IntPtr.Zero; //Default Connection optionList.optionCount = options.Length; optionList.optionError = 0; optionList.options = VarPtr(options); var optionListSize = Marshal.SizeOf(optionList); var optionListPtr = Marshal.AllocCoTaskMem(optionListSize); Marshal.StructureToPtr(optionList, optionListPtr, true); bool iReturn; iReturn = WinInet.InternetSetOption(IntPtr.Zero, (int)InternetOption.INTERNET_OPTION_PER_CONNECTION_OPTION, optionListPtr, Marshal.SizeOf(optionList)); if (iReturn == false) { var exception = new Win32Exception(Marshal.GetLastWin32Error()); throw exception; } iReturn = InternetOptionSettingsChanged(); //if (iReturn == true) //{ // iReturn = InternetOptionRefresh(); //} // free the COM memory Marshal.FreeCoTaskMem(optionListPtr); return(iReturn); }
public static bool InternetOptionRefresh() { return(WinInet.InternetSetOption(IntPtr.Zero, (int)InternetOption.INTERNET_OPTION_REFRESH, IntPtr.Zero, 0)); }
public static bool InternetOptionSettingsChanged() { return(WinInet.InternetSetOption(IntPtr.Zero, (int)InternetOption.INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0)); }