Browse Source

format

tags/2.3
clowwindy 9 years ago
parent
commit
07dc69fbc9
1 changed files with 49 additions and 37 deletions
  1. +49
    -37
      shadowsocks-csharp/Controller/AutoStartup.cs

+ 49
- 37
shadowsocks-csharp/Controller/AutoStartup.cs View File

@@ -1,43 +1,55 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using Microsoft.Win32;

namespace Shadowsocks.Controller {
class AutoStartup {
public static bool Set(bool enabled) {
try {
string path = Application.ExecutablePath;
RegistryKey runKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
if (enabled) {
runKey.SetValue("Shadowsocks", path);
} else {
runKey.DeleteValue("Shadowsocks");
}
runKey.Close();
return true;
} catch (Exception e) {
Logging.LogUsefulException(e);
return false;
}
}

public static bool Check() {
try {
string path = Application.ExecutablePath;
RegistryKey runKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
string[] runList = runKey.GetValueNames();
runKey.Close();
foreach (string item in runList) {
if (item.Equals("Shadowsocks"))
return true;
}
return false;
using Microsoft.Win32;
namespace Shadowsocks.Controller
{
class AutoStartup
{
public static bool Set(bool enabled)
{
try
{
string path = Application.ExecutablePath;
RegistryKey runKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
if (enabled)
{
runKey.SetValue("Shadowsocks", path);
}
else
{
runKey.DeleteValue("Shadowsocks");
}
runKey.Close();
return true;
} }
catch (Exception e) catch (Exception e)
{ {
Logging.LogUsefulException(e);
return false;
}
}
}
Logging.LogUsefulException(e);
return false;
}
}
public static bool Check()
{
try
{
string path = Application.ExecutablePath;
RegistryKey runKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
string[] runList = runKey.GetValueNames();
runKey.Close();
foreach (string item in runList)
{
if (item.Equals("Shadowsocks"))
return true;
}
return false;
}
catch (Exception e)
{
Logging.LogUsefulException(e);
return false;
}
}
}
} }

Loading…
Cancel
Save