private ThemeManager() { themeWatcher = new RegistryWatcher <int>(ThemeRegistryPath, ThemeRegistryKey, GetDefaultKeys()); themeWatcher.ValueChanged += ThemeChangedHandler; themeWatcher.Fire(); themeWatcher.Start(); }
private ThemeManager() { // The ThemeWatcher will have no default keys. themeWatcher = new RegistryWatcher <int>(ThemeRegistryPath, ThemeRegistryKey, new List <int>()); themeWatcher.ValueChanged += ThemeChangedHandler; themeWatcher.Fire(); themeWatcher.Start(); }
public void Config(BeSafeConfig config, PipeServer pipeServer, bool stoppingService) { _config = config; _pipeServer = pipeServer; bool stateResult; if ((config?.ComponentsState.RegistryWatcher == true) && (stoppingService == false)) { string userSID = config.UserSID; _registryWatcher = new RegistryWatcher(new List <RegistryMonitorPath> { // CurrentUser keys new RegistryMonitorPath { RegistryHive = RegistryHive.Users, RegistryKeyPath = $@"{userSID}\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" }, new RegistryMonitorPath { RegistryHive = RegistryHive.Users, RegistryKeyPath = $@"{userSID}\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" }, new RegistryMonitorPath { RegistryHive = RegistryHive.Users, RegistryKeyPath = $@"{userSID}\Software\Microsoft\Windows\CurrentVersion\RunServices" }, new RegistryMonitorPath { RegistryHive = RegistryHive.Users, RegistryKeyPath = $@"{userSID}\Software\Microsoft\Windows\CurrentVersion\Run" }, new RegistryMonitorPath { RegistryHive = RegistryHive.Users, RegistryKeyPath = $@"{userSID}\Software\Microsoft\Windows\CurrentVersion\RunOnce" }, // LocalMachine keys new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\explorer\Shell Folders" }, new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\explorer\User Shell Folders" }, new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\RunServices" }, new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\RunServicesOnce" }, new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Run" }, new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\RunOnce" }, new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"SOFTWARE\Classes\cplfile\shell\cplopen\command" }, new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"SOFTWARE\Classes\batfile\shell\open\command" }, new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"Software\CLASSES\comfile\shell\open\command" }, new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"Software\CLASSES\exefile\shell\open\command" }, new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"Software\CLASSES\htafile\Shell\Open\Command" }, new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"Software\CLASSES\piffile\shell\open\command" }, new RegistryMonitorPath { RegistryHive = RegistryHive.LocalMachine, RegistryKeyPath = @"SOFTWARE\Classes\scrfile\shell\open\command" }, }); _registryWatcher.ValueChanged += ValueChangedArrived; stateResult = _registryWatcher.Start(); Task.Run(() => StackScanner(_changedValuesStack)); return; } stateResult = _registryWatcher?.Stop() ?? false; }