Beispiel #1
0
        /// <summary>
        /// Processes a registry key.
        /// </summary>
        /// <param name="rk">A registry key.</param>
        /// <returns>
        /// True if the given registry key is found. The Inverse
        /// property may be used to invert the returned value.
        /// </returns>
        private static bool ProcessRegKey(RegKey rk)
        {
            var frk = rk.X64
                ? RegUtils.OpenKey(
                    rk.Path, false, RegUtils.ProcessArchitecture.X64)
                : RegUtils.OpenKey(rk.Path);

            var frkIsNull = frk == null;

            if (!frkIsNull)
            {
                frk.Close();
            }

            return rk.Inverse ? frkIsNull : !frkIsNull;
        }
Beispiel #2
0
        /// <summary>
        /// Processes a registry key.
        /// </summary>
        /// <param name="rk">A registry key.</param>
        /// <returns>
        /// True if the given registry key is found. The Inverse
        /// property may be used to invert the returned value.
        /// </returns>
        private static bool ProcessRegKey(RegKey rk)
        {
            var p = rk.Path;
            RegistryKey frk = null;

            if (p.StartsWith(@"HKCR"))
            {
                p = p.Replace(@"HKCR\", string.Empty);
                frk = Registry.ClassesRoot.OpenSubKey(p);
            }
            else if (p.StartsWith(@"HKCU"))
            {
                p = p.Replace(@"HKCU\", string.Empty);
                frk = Registry.CurrentUser.OpenSubKey(p);
            }
            else if (p.StartsWith(@"HKLM"))
            {
                p = p.Replace(@"HKLM\", string.Empty);
                frk = Registry.LocalMachine.OpenSubKey(p);
            }
            else if (p.StartsWith(@"HKU"))
            {
                p = p.Replace(@"HKU\", string.Empty);
                frk = Registry.Users.OpenSubKey(p);
            }
            else if (p.StartsWith(@"HKCC"))
            {
                p = p.Replace(@"HKCC\", string.Empty);
                frk = Registry.CurrentConfig.OpenSubKey(p);
            }
            else if (p.StartsWith(@"HKPD"))
            {
                p = p.Replace(@"HKPD\", string.Empty);
                frk = Registry.PerformanceData.OpenSubKey(p);
            }

            return rk.Inverse ? frk == null : frk != null;
        }