Exemplo n.º 1
0
        private void OnRegistryKeyChanged(object sender, EventArgs e)
        {
            // ensure that we can get the information about the registry key and save it
            RegistryMonitor regMon = sender as RegistryMonitor;

            if (regMon != null)
            {
                SaveRegistryKey(regMon.RegistryKey);
            }
        }
Exemplo n.º 2
0
        public void Initialize(Dictionary <string, string> registryKeysToMonitor)
        {
            if (registryKeysToMonitor == null)
            {
                throw new ArgumentNullException("registryKeysToMonitor");
            }

            lock (_syncRoot)
            {
                _registryKeysToMonitor = registryKeysToMonitor;

                foreach (string regKey in _registryKeysToMonitor.Keys)
                {
                    _logger.DebugFormat("Creating watcher for registry key '{0}'", regKey);
                    RegistryMonitor regMon = new RegistryMonitor(regKey, _logger);

                    _regKeyMonitors.Add(regKey, regMon);
                }
                SubscribeToEvents();
            }
        }
Exemplo n.º 3
0
        public void Add(string regKey, string identifier = null)
        {
            if (_registryKeysToMonitor.Keys.Contains(regKey))
            {
                return;                                               // key is already monitored
            }
            lock (_syncRoot)
            {
                _registryKeysToMonitor.Add(regKey, identifier);

                var regMon = new RegistryMonitor(regKey, _logger);
                if (IsMonitoring)
                {
                    regMon.Start();
                }

                _regKeyMonitors.Add(regKey, regMon);

                SubscribeToEvents();
            }
        }
Exemplo n.º 4
0
 private void UnsubscribeToEvents(RegistryMonitor regMon)
 {
     regMon.RegChanged -= OnRegistryKeyChanged;
 }