never use string.Equals(string) if you don't know what you are doing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Shadowsocks.Controller
|
||||
@@ -14,7 +14,7 @@ namespace Shadowsocks.Controller
|
||||
try
|
||||
{
|
||||
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)
|
||||
{
|
||||
runKey.SetValue(Key, path);
|
||||
@@ -47,13 +47,13 @@ namespace Shadowsocks.Controller
|
||||
try
|
||||
{
|
||||
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();
|
||||
foreach (string item in runList)
|
||||
{
|
||||
if (item.Equals(Key))
|
||||
if (item == Key)
|
||||
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));
|
||||
if (path.Equals(value, StringComparison.InvariantCultureIgnoreCase))
|
||||
@@ -82,4 +82,4 @@ namespace Shadowsocks.Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user