zoukankan      html  css  js  c++  java
  • IE代理的设置与取消

    要实时更新IE所有实例需调用如下API:

    [DllImport("wininet.dll", SetLastError = true)]
            
    private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength);

    然后刷新IE设置:

    private static void RefreshIESettings()
            {
                
    const int INTERNET_OPTION_REFRESH = 0x000025;
                
    const int INTERNET_OPTION_SETTINGS_CHANGED = 0x000027;
                InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 
    0);
                InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 
    0);
            }

    最后写IE在注册表中的设置即可:

    public static void SetIEProxy(Proxy proxy)
            
    {
                
    string proxyIP = "";
                proxyIP
    =string.Format("{0}:{1}", proxy.ProxyAddr, proxy.ProxyPort);
                RegistryKey rk 
    = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings"true);
                rk.SetValue(
    "ProxyEnable"1);
                rk.SetValue(
    "ProxyServer", proxyIP);
                rk.Close();
                RefreshIESettings();
            }


            
    public static void CancelIEProxy()
            
    {
                RegistryKey rk 
    = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings",true);
                rk.SetValue(
    "ProxyEnable"0);
                rk.Close();
                RefreshIESettings();
            }


    public class Proxy
        
    {
            
    private string proxyName;
            
    private string proxyAddr;
            
    private int port;

            
    public Proxy(string name, string addr, int port)
            
    {
                
    this.proxyName = name;
                
    this.proxyAddr = addr;
                
    this.port = port;
            }


            
    public string ProxyName get return proxyName; } }
            
    public string ProxyAddr get return proxyAddr; } }
            
    public int ProxyPort get return port; } }

            
    public override string ToString()
            
    {
                
    return proxyName;
            }

        }
  • 相关阅读:
    pydensecrf的inference.py代码的学习
    pydensecrf的使用
    Example of DenseCRF with non-RGB data
    scipy.stats.multivariate_normal的使用
    np.mgrid的用法
    Linux后台命令的使用说明
    实现能够在训练过程中手动更改学习率
    pytorch Debug —交互式调试工具Pdb (ipdb是增强版的pdb)-1-在pytorch中使用
    pytorch实现性别检测
    svn冲突意思
  • 原文地址:https://www.cnblogs.com/wudingfeng/p/1310246.html
Copyright © 2011-2022 走看看