예제 #1
0
        /// <summary>
        /// register all the monitors that must watch registry entries.
        /// </summary>
        static private void SetKeyMonitors()
        {
            List <String> monitoredPaths = new List <string>();

            foreach (Key key in keys)
            {
                if (!monitoredPaths.Contains(key.path))
                {
                    try
                    {
                        RegistryMonitor monitor = new RegistryMonitor(key.path);
                        monitor.RegChanged += new EventHandler(OnRegChanged);
                        monitor.Start();
                        Console.WriteLine("Monitoring " + key.path);
                        monitoredPaths.Add(key.path);
                    } catch (ArgumentException ae)
                    {
                        Console.WriteLine("Error: Unable to monitor the key " + key.path + "\\" + key.name + " " + ae.Message);
                    }
                }
            }
            Console.WriteLine();
        }
        /// <summary>
        /// register all the monitors that must watch registry entries.
        /// </summary>
        private static void SetKeyMonitors()
        {
            List<String> monitoredPaths = new List<string>();
            foreach (Key key in keys)
            {
                if (!monitoredPaths.Contains(key.path))
                {
                    try
                    {
                        RegistryMonitor monitor = new RegistryMonitor(key.path);
                        monitor.RegChanged += new EventHandler(OnRegChanged);
                        monitor.Start();
                        Console.WriteLine("Monitoring " + key.path);
                        monitoredPaths.Add(key.path);

                    } catch (ArgumentException ae)
                    {
                        Console.WriteLine("Error: Unable to monitor the key " + key.path + "\\" + key.name + " " + ae.Message);
                    }
                }
            }
            Console.WriteLine();
        }