Hush – Blame information for rev 2

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using System.Reflection;
2 using Microsoft.Win32;
3  
4 namespace Hush.Utilities
5 {
6 public static class LaunchOnBoot
7 {
8 public static bool Set(bool enable)
9 {
10 using (var key = Registry.CurrentUser.OpenSubKey
11 ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
12 {
13 if (key == null)
14 return false;
15  
16 switch (enable)
17 {
18 case true:
2 office 19 key.SetValue(Constants.AssemblyName, Assembly.GetEntryAssembly().Location);
1 office 20 break;
21 default:
2 office 22 key.DeleteValue(Constants.AssemblyName, false);
1 office 23 break;
24 }
25 }
26  
27 return true;
28 }
29  
30 public static bool Get()
31 {
32 using (var key = Registry.CurrentUser.OpenSubKey
33 ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
34 {
2 office 35 return key?.GetValue(Constants.AssemblyName) != null;
1 office 36 }
37 }
38 }
39 }