Beispiel #1
0
        /// <include file='doc\PerformanceCounterInstaller.uex' path='docs/doc[@for="PerformanceCounterInstaller.Install"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public override void Install(IDictionary stateSaver)
        {
            base.Install(stateSaver);

            Context.LogMessage(Res.GetString(Res.CreatingPerformanceCounter, CategoryName));

            RegistryKey categoryKey = null;
            RegistryKey servicesKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services", true);

            if (servicesKey != null)
            {
                categoryKey = servicesKey.OpenSubKey(CategoryName);

                if (categoryKey != null)
                {
                    stateSaver["categoryKeyData"] = new SerializableRegistryKey(categoryKey);
                    categoryKey.Close();
                    servicesKey.DeleteSubKeyTree(CategoryName);
                }
            }

            PerformanceCounterCategory.Create(CategoryName, CategoryHelp, Counters);
        }