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