GetSubKeyNames() private method

private GetSubKeyNames ( [ root, [ key ) : string[]
root [
key [
return string[]
Exemplo n.º 1
0
        /// <summary>
        /// Retrieves data about multiple verbs (executable commands) from the registry.
        /// </summary>
        /// <param name="typeKey">The registry key containing information about the file type / protocol the verbs belong to.</param>
        /// <param name="commandMapper">Provides best-match command-line to <see cref="Command"/> mapping.</param>
        /// <returns>A list of detected <see cref="Verb"/>.</returns>
        private static IEnumerable <Verb> GetVerbs(RegistryKey typeKey, CommandMapper commandMapper)
        {
            #region Sanity checks
            if (typeKey == null)
            {
                throw new ArgumentNullException(nameof(typeKey));
            }
            if (commandMapper == null)
            {
                throw new ArgumentNullException(nameof(commandMapper));
            }
            #endregion

            return(RegUtils.GetSubKeyNames(typeKey, "shell").Select(verbName => GetVerb(typeKey, commandMapper, verbName)).WhereNotNull());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves a list of service associations from the registry.
        /// </summary>
        /// <exception cref="IOException">There was an error accessing the registry.</exception>
        /// <exception cref="UnauthorizedAccessException">Read access to the registry was not permitted.</exception>
        private static ComparableTuple <string>[] GetServiceAssocs()
        {
            using var clientsKey = Registry.LocalMachine.OpenSubKey(DefaultProgram.RegKeyMachineClients);
            if (clientsKey == null)
            {
                return(new ComparableTuple <string> [0]);
            }

            return((
                       from serviceName in clientsKey.GetSubKeyNames()
                       // ReSharper disable AccessToDisposedClosure
                       from clientName in RegUtils.GetSubKeyNames(clientsKey, serviceName)
                       // ReSharper restore AccessToDisposedClosure
                       select new ComparableTuple <string>(serviceName, clientName)).ToArray());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Stores information about the current state of the registry in a snapshot.
        /// </summary>
        /// <exception cref="IOException">There was an error accessing the registry.</exception>
        /// <exception cref="UnauthorizedAccessException">Read access to the registry was not permitted.</exception>
        private void TakeRegistry()
        {
            ServiceAssocs           = GetServiceAssocs();
            AutoPlayHandlersUser    = RegUtils.GetSubKeyNames(Registry.CurrentUser, AutoPlay.RegKeyHandlers);
            AutoPlayHandlersMachine = RegUtils.GetSubKeyNames(Registry.LocalMachine, AutoPlay.RegKeyHandlers);
            AutoPlayAssocsUser      = GetAutoPlayAssocs(Registry.CurrentUser);
            AutoPlayAssocsMachine   = GetAutoPlayAssocs(Registry.LocalMachine);
            (FileAssocs, ProgIDs)   = GetFileAssocData();
            ProtocolAssocs          = GetProtocolAssoc();
            ClassIDs = RegUtils.GetSubKeyNames(Registry.ClassesRoot, ComServer.RegKeyClassesIDs);
            RegisteredApplications = RegUtils.GetValueNames(Registry.LocalMachine, AppRegistration.RegKeyMachineRegisteredApplications);

            ContextMenuFiles           = RegUtils.GetSubKeyNames(Registry.ClassesRoot, ContextMenu.RegKeyClassesFiles + @"\shell");
            ContextMenuExecutableFiles = RegUtils.GetSubKeyNames(Registry.ClassesRoot, ContextMenu.RegKeyClassesExecutableFiles + @"\shell");
            ContextMenuDirectories     = RegUtils.GetSubKeyNames(Registry.ClassesRoot, ContextMenu.RegKeyClassesDirectories + @"\shell");
            ContextMenuAll             = RegUtils.GetSubKeyNames(Registry.ClassesRoot, ContextMenu.RegKeyClassesAll + @"\shell");
        }