Browse Source

never use string.Equals(string) if you don't know what you are doing

tags/3.0
Licshee 8 years ago
parent
commit
24609bf53b
1 changed files with 7 additions and 7 deletions
  1. +7
    -7
      shadowsocks-csharp/Controller/System/AutoStartup.cs

+ 7
- 7
shadowsocks-csharp/Controller/System/AutoStartup.cs View File

@@ -1,5 +1,5 @@
using System;
using System.Windows.Forms;
using System;
using System.Windows.Forms;
using Microsoft.Win32; using Microsoft.Win32;
namespace Shadowsocks.Controller namespace Shadowsocks.Controller
@@ -14,7 +14,7 @@ namespace Shadowsocks.Controller
try try
{ {
string path = Application.ExecutablePath; string path = Application.ExecutablePath;
runKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
runKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
if (enabled) if (enabled)
{ {
runKey.SetValue(Key, path); runKey.SetValue(Key, path);
@@ -47,13 +47,13 @@ namespace Shadowsocks.Controller
try try
{ {
string path = Application.ExecutablePath; string path = Application.ExecutablePath;
runKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
runKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
string[] runList = runKey.GetValueNames(); string[] runList = runKey.GetValueNames();
foreach (string item in runList) foreach (string item in runList)
{ {
if (item.Equals(Key))
if (item == Key)
return true; return true;
else if (item.Equals("Shadowsocks")) // Compatibility with older versions
else if (item == "Shadowsocks") // Compatibility with older versions
{ {
string value = Convert.ToString(runKey.GetValue(item)); string value = Convert.ToString(runKey.GetValue(item));
if (path.Equals(value, StringComparison.InvariantCultureIgnoreCase)) if (path.Equals(value, StringComparison.InvariantCultureIgnoreCase))
@@ -82,4 +82,4 @@ namespace Shadowsocks.Controller
} }
} }
} }
}
}

Loading…
Cancel
Save