change the registry, here is some C++ code:
Change Internet Proxy settings
http://www.codeproject.com/internet/changeproxy1.aspToggle Internet Proxy settings - an alternate approach
http://www.codeproject.com/internet/changeproxy2.asp

解决方案 »

  1.   

    你可以在C#中调用系统的SHELL命令 cmd /k netsh -f tt.txttt.txt,假设是你的网络配置文件,由SHELL 命令 cmd /k netsh -c interface dump > tt.txt 生成
      

  2.   

    有没有更加简单的方法啊??to  xamcsdn2(知了) :可否给一个tt.txt的例子啊:)
      

  3.   

    System.Net.GlobalProxySelection.Select
      

  4.   

    to  gujunyan(ivy):这种方法不能更改internet选项的代理设置。因为我的http请求是从ie而不是.net的WebRequest发出的,所以这种方法不能满足我的要求啊。
      

  5.   

    tt.txt可以自己生成。在CMD窗口下输入
    netsh -c interface dump > c:\tt.txt
    ----------------------------------------------
    #========================
    # 接口配置
    #========================
    pushd interfacereset all
    popd
    # 接口配置结束# ---------------------------------- 
    # 接口 IP 配置         
    # ---------------------------------- 
    pushd interface ip
    # "本地连接" 的接口 IP  配置set address name = "本地连接" source = static addr = 202.168.0.224 mask = 255.255.255.0
    set address name = "本地连接" gateway = 192.168.0.1 gwmetric = 1
    set dns name = "本地连接" source = static addr = 202.135.0.1
    set wins name = "本地连接" source = static addr = none
    popd
    # 接口 IP 配置结束
      

  6.   

    to  xamcsdn2(知了):
      无法得到代理服务的信息
      

  7.   

    问题已解决,谢谢大家帮助:
    以下是c#代码//申明windows api
    [DllImport(@"wininet",
     SetLastError=true,
     CharSet=CharSet.Auto,
     EntryPoint="InternetSetOption",
     CallingConvention=CallingConvention.StdCall)]
    public static extern bool InternetSetOption
    (
    int hInternet,
    int dmOption,
    IntPtr lpBuffer,
    int dwBufferLength
    );public static void SetProxy()
    {
       //打开注册表
       RegistryKey regKey = Registry.CurrentUser;
       string SubKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";
       RegistryKey optionKey = regKey.OpenSubKey(SubKeyPath,true);
       //更改健值,设置代理,
       optionKey.SetValue("ProxyEnable",1);
       optionKey.SetValue("ProxyServer","192.168.1.85:80");

       //激活代理设置
       InternetSetOption(0,39,IntPtr.Zero,0);
       InternetSetOption(0,37,IntPtr.Zero,0);
    }
      

  8.   

    问题已解决,谢谢大家帮助:
    以下是c#代码//申明windows api
    [DllImport(@"wininet",
     SetLastError=true,
     CharSet=CharSet.Auto,
     EntryPoint="InternetSetOption",
     CallingConvention=CallingConvention.StdCall)]
    public static extern bool InternetSetOption
    (
    int hInternet,
    int dmOption,
    IntPtr lpBuffer,
    int dwBufferLength
    );public static void SetProxy()
    {
       //打开注册表
       RegistryKey regKey = Registry.CurrentUser;
       string SubKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";
       RegistryKey optionKey = regKey.OpenSubKey(SubKeyPath,true);
       //更改健值,设置代理,
       optionKey.SetValue("ProxyEnable",1);
       optionKey.SetValue("ProxyServer","192.168.1.85:80");

       //激活代理设置
       InternetSetOption(0,39,IntPtr.Zero,0);
       InternetSetOption(0,37,IntPtr.Zero,0);
    }