-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
58 lines (47 loc) · 1.53 KB
/
Program.cs
File metadata and controls
58 lines (47 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using Microsoft.Win32;
using ProcessWatcher.Classes;
using ProcessWatcher.Process;
using System;
using System.Windows.Forms;
namespace ProcessWatcher
{
static class App
{
public static Config Cfg;
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Cfg = Config.Load();
StartMonitor();
if(Cfg.Web.Enabled)
APIServer.Nancy.Start();
Application.Run(new MainForm());
}
public static void OnProcessExit()
{
foreach (ProcessContainer pw in ServerFactory.servers)
pw.CloseProcess();
ServerFactory.Save();
}
static void StartMonitor()
{
ServerFactory.OnServerAdded += ServerFactory_OnServerAdded;
ServerFactory.Load();
}
private static void ServerFactory_OnServerAdded(ProcessContainer pc)
{
util.Log($"Server '{pc.ProcName}': {pc.Path} was added.");
ServerFactory.Save();
}
private static void RunOnStartUp(bool run)
{
RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (run)
rk.SetValue(AppDomain.CurrentDomain.FriendlyName, Application.ExecutablePath);
else
rk.DeleteValue(AppDomain.CurrentDomain.FriendlyName, false);
}
}
}