Hush – Blame information for rev 1

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:
19 key.SetValue(Constants.ASSEMBLY_NAME, Assembly.GetEntryAssembly().Location);
20 break;
21 default:
22 key.DeleteValue(Constants.ASSEMBLY_NAME, false);
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 {
35 return key?.GetValue(Constants.ASSEMBLY_NAME) != null;
36 }
37 }
38 }
39 }