diff --git a/shadowsocks-csharp/Controller/SystemProxy.cs b/shadowsocks-csharp/Controller/SystemProxy.cs index c16aa23..fa3c5a8 100755 --- a/shadowsocks-csharp/Controller/SystemProxy.cs +++ b/shadowsocks-csharp/Controller/SystemProxy.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; +using System.IO; namespace Shadowsocks.Controller { @@ -79,18 +80,24 @@ namespace Shadowsocks.Controller RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Connections", true); - var defulatValue = registry.GetValue("DefaultConnectionSettings"); - var connections = registry.GetValueNames(); - foreach (String each in connections){ - if (!(each.Equals("DefaultConnectionSettings") - || each.Equals("LAN Connection") - || each.Equals("SavedLegacySettings"))) + var defaultValue = registry.GetValue("DefaultConnectionSettings"); + try + { + var connections = registry.GetValueNames(); + foreach (String each in connections) { - //set all the connections's proxy as the lan - registry.SetValue(each, defulatValue); + if (!(each.Equals("DefaultConnectionSettings") + || each.Equals("LAN Connection") + || each.Equals("SavedLegacySettings"))) + { + //set all the connections's proxy as the lan + registry.SetValue(each, defaultValue); + } } + SystemProxy.NotifyIE(); + } catch (IOException e) { + Logging.LogUsefulException(e); } - NotifyIE(); } private static String GetTimestamp(DateTime value)