怎么样设置ie的Socket代理?我知道一般设置ie代理,是通过修改注册表里相应的值来达到目的!
但这样修改出来的结果是修改ie中的http代理。
而ie代理中有http,ftp,Socket代理等。我 现在的问题就是怎么样通过编写程序修改ie的Socket代理???望各位,多指点!!!!

解决方案 »

  1.   

    参考http://www.cnblogs.com/ttyp/archive/2005/11/18/279124.html
      

  2.   

    http://www.cnblogs.com/ttyp/archive/2005/11/18/279124.html
      

  3.   

    感谢这么快就有回复!!刚才两位提供的思路我都看了!!
    有几个问题:
    1.怎么样动态的修改ie的Socket代理。
    2.就是我用的是c#编写代码,怎么样把这个脚本转换为c#代码啊。
    望各位,多指点!!!! 
      

  4.   

    自已写个脚本然后你执行这个脚本,也可以直接修改注册表
    注:其中 61.166.68.71 代表IP,80代表端口号@rem SetIeProxy.bat Createdby fanfeng
    title Set IE Proxy
    @echo off
    :start
    cls
    echo.****************************************************************************
    echo        [0] Stop Proxy
    echo        [1] Use Proxy
    echo        [q] Quit
    echo.****************************************************************************set /p choice=Please Choose:
    if /i "%choice%"=="0" goto SP
    if /i "%choice%"=="1" goto Proxy
    if /i "%choice%"=="q" goto end:Proxy
    echo Please wait.....It will be configured automatically when finished......
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "61.166.68.71:80" /f
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d "<local>" /f
    echo The JPNProxy enabled
    echo Press any key to return
    pause>nul
    goto start
    :SP
    echo Please wait.....It will be closed automatically when finished......
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "" /f
    echo The Proxy has been stopped
    echo Press any key to return
    pause>nul
    goto start:end
    exit
      

  5.   

    是啊,现在还是没头绪!!我不想用脚本来实现。。刚才在百度了下,有点思路就是调用DllImport("wininet.dll"]
    但是我这方面根本就不知道是怎么回事!!!望各位,多指点啊!!
      

  6.   

    算小弟愚笨
    自己也直接操作过注册表但设置出来的是http的代理,而不是scoket代理。
      

  7.   

    我刚才在网上找到这样一段代码!!
    不是很明白!!望大家帮忙解释下!!
    Public struct Struct_INTERNET_PROXY_INFO 

    public int dwAccessType; 
    public IntPtr proxy; 
    public IntPtr proxyBypass; 
    }; [DllImport("wininet.dll", SetLastError = true)] 
    private static extern bool InternetSetOption(IntPtr hInternet, 
    int dwOption, 
    IntPtr lpBuffer, 
    int lpdwBufferLength); private void RefreshIESettings(string strProxy) 

    const int INTERNET_OPTION_PROXY = 38; 
    const int INTERNET_OPEN_TYPE_PROXY = 3; Struct_INTERNET_PROXY_INFO struct_IPI; // Filling in structure 
    struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY; 
    struct_IPI.proxy = Marshal.StringToHGlobalAnsi(strProxy); 
    struct_IPI.proxyBypass = Marshal.StringToHGlobalAnsi("local"); // Allocating memory 
    IntPtr intptrStruct = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI)); // Converting structure to IntPtr 
    Marshal.StructureToPtr(struct_IPI, intptrStruct, true); bool iReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, Marshal.SizeOf(struct_IPI)); 
    } private void SomeFunc() 

    RefreshIESettings("1.2.3.4:8080"); 
    //or RefreshIESettings("http://1.2.3.4:8080"); //both worked 
    //or RefreshIESettings("http=1.2.3.4:8080"); //both worked System.Object nullObject = 0; 
    string strTemp = ""; 
    System.Object nullObjStr = strTemp; 
    axWebBrowser1.Navigate("http://willstay.tripod.com", ref nullObject, ref nullObjStr, ref nullObjStr, ref nullObjStr); 
      

  8.   

    代理信息结构体
    Public struct Struct_INTERNET_PROXY_INFO 

    public int dwAccessType; 
    public IntPtr proxy; 
    public IntPtr proxyBypass; 
    }; dll调用声明
    [DllImport("wininet.dll", SetLastError = true)] 
    private static extern bool InternetSetOption(IntPtr hInternet, 
    int dwOption, 
    IntPtr lpBuffer, 
    int lpdwBufferLength);通过调用wininet.dll里面的InternetSetOption来设置你的proxy
    private void RefreshIESettings(string strProxy) 

    const int INTERNET_OPTION_PROXY = 38; 
    const int INTERNET_OPEN_TYPE_PROXY = 3; Struct_INTERNET_PROXY_INFO struct_IPI; // Filling in structure 
    struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY; 
    struct_IPI.proxy = Marshal.StringToHGlobalAnsi(strProxy); 
    struct_IPI.proxyBypass = Marshal.StringToHGlobalAnsi("local"); // Allocating memory 
    IntPtr intptrStruct = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI)); // Converting structure to IntPtr 
    Marshal.StructureToPtr(struct_IPI, intptrStruct, true); bool iReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, Marshal.SizeOf(struct_IPI)); 

    这个就是测试了
    private void SomeFunc() 

    RefreshIESettings("1.2.3.4:8080"); 
    //or RefreshIESettings("http://1.2.3.4:8080"); //both worked 
    //or RefreshIESettings("http=1.2.3.4:8080"); //both worked System.Object nullObject = 0; 
    string strTemp = ""; 
    System.Object nullObjStr = strTemp; 
    axWebBrowser1.Navigate("http://willstay.tripod.com", ref nullObject, ref nullObjStr, ref nullObjStr, ref nullObjStr);