예제 #1
0
        void RefreshIESettings(string strProxy)
        {
            WebBrowserHelper.ClearCache();
            const int INTERNET_OPTION_PROXY    = 38;
            const int INTERNET_OPEN_TYPE_PROXY = 3;
            Struct_INTERNET_PROXY_INFO s_IPI;

            s_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
            s_IPI.proxy        = Marshal.StringToHGlobalAnsi(strProxy);
            s_IPI.proxyBypass  = Marshal.StringToHGlobalAnsi("Global");

            IntPtr intptrStruct = Marshal.AllocCoTaskMem(Marshal.SizeOf(s_IPI));

            InternetSetOption(IntPtr.Zero, 81, intptrStruct, 0); // clear cookies
            //InternetSetOption(IntPtr.Zero, 42, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(s_IPI)); // flush cache (crashes in win10)
            InternetSetOption(IntPtr.Zero, 1, intptrStruct, 0);  // allow all cookies

            if (strProxy != ":")                                 //if we have a proxy:port
            {
                Marshal.StructureToPtr(s_IPI, intptrStruct, true);
                InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, Marshal.SizeOf(s_IPI)); // set proxy
            }
        }
예제 #2
0
        void RefreshIESettings(string strProxy)
        {
            WebBrowserHelper.ClearCache();

            try
            {
                string[] theCookies = System.IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Cookies));
                foreach (string currentFile in theCookies)
                {
                    System.IO.File.Delete(currentFile);
                }
            }
            catch
            {
                MessageBox.Show("error deleting cookies");
            }

            const int INTERNET_OPTION_PROXY    = 38;
            const int INTERNET_OPEN_TYPE_PROXY = 3;
            Struct_INTERNET_PROXY_INFO s_IPI;

            s_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
            s_IPI.proxy        = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(strProxy);
            s_IPI.proxyBypass  = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("Global");

            IntPtr intptrStruct = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(s_IPI));

            InternetSetOption(IntPtr.Zero, 81, intptrStruct, 0); // clear cookies
            //InternetSetOption(IntPtr.Zero, 42, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(s_IPI)); // flush cache (crashes in win10)
            InternetSetOption(IntPtr.Zero, 1, intptrStruct, 0);  // allow all cookies

            if (strProxy != ":")                                 //if we have a proxy:port
            {
                System.Runtime.InteropServices.Marshal.StructureToPtr(s_IPI, intptrStruct, true);
                InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(s_IPI)); // set proxy
            }
        }