试试WMI吧,
http://www.cnblogs.com/dahuzizyd/archive/2004/08/17/34058.aspx
后面评论里提供的程序也不错

解决方案 »

  1.   

    use System.Net.WebProxy's GetDefaultProxy method, for example System.Net.WebProxy wp = System.Net.WebProxy.GetDefaultProxy();
    Uri u = wp.Address;
    Console.WriteLine(u.ToString());
    Console.WriteLine(u.Host);
    Console.WriteLine(u.Port);
      

  2.   

    可以用WMI,但推荐使用注册表,因为效率要高。下面把两种方法都告诉你。WMI:
    string proxyServer = null;
    ManagementClass mc = new ManagementClass("Win32_Proxy");
    ManagementObjectCollection moc = mc.GetInstances();
    foreach(ManagementObject mo in moc)
    {
        proxyServer=(string)mo["ProxyServer"]+":"+(string)mo["ProxyPortNumber"];
    }注册表:
    private RegistryKey _InternetSettings = currentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true);
    string value = (string)_InternetSettings.GetValue( "ProxyServer", string.Empty );
    _InternetSettings.Close();用WMI可分别获得代理地址和端口,用注册表获得的是代理的完整地址(地址:端口)。
      

  3.   

    Public Function GetProxyServerName() As String        Dim UseProxy As New Net.WebProxy()
            Try 'if no proxy is specified, an exception is 
                'thrown by the frameworks and must be caught            Return UseProxy.GetDefaultProxy.Address.Host        Catch 'catch the error when no proxy is specified in IE            Return "Not Specified"        End Try    End Function
        Public Function GetProxyServerPort() As String        Dim UseProxy As New Net.WebProxy()        Try 'if no proxy is specified, an exception is 
                'thrown by the frameworks and must be caught            Return UseProxy.GetDefaultProxy.Address.Port        Catch 'catch the error when no proxy is specified in IE            Return "Not Specified"        End Try    End Function