Example #1
0
        public void ProcessValues(RegistryKey key)
        {
            _values.Clear();
            Errors.Clear();

            var currentKey = string.Empty;

            try
            {
                foreach (var registryKey in key.SubKeys) // subkeys of FileExts
                {
                    currentKey = registryKey.KeyName;

                    var oe = new List <string>();
                    var op = new List <string>();
                    var uc = "(UserChoice key not present)";

                    if (registryKey.SubKeys.Count == 0)
                    {
                        var progId = registryKey.Values.SingleOrDefault(t => t.ValueName == "Progid");
                        if (progId != null)
                        {
                            op.Add(progId.ValueData);
                        }
                        var vo1 = new ValuesOut(registryKey.KeyName, string.Join(", ", oe), string.Join(", ", op), uc);

                        _values.Add(vo1);
                        continue;
                    }


                    foreach (var subKey in registryKey.SubKeys) // subkey's subkeys
                    {
                        switch (subKey.KeyName)
                        {
                        case "OpenWithList":
                            // contains values with name == char and value data of an executable name
                            //there is an MRUList that contains the order the executables were selected

                            var mruList = subKey.Values.SingleOrDefault(t => t.ValueName == "MRUList");

                            if (mruList != null)
                            {
                                //foreach slot in MRU, get the value and append it to our oe variable

                                foreach (var mruPos in mruList.ValueData.ToCharArray())
                                {
                                    var exeName =
                                        subKey.Values.SingleOrDefault(t => t.ValueName == mruPos.ToString());

                                    if (exeName != null)
                                    {
                                        oe.Add(exeName.ValueData);
                                    }
                                    else
                                    {
                                        oe.Add($"(Executable name for MRU slot '{mruPos}' not found!)");
                                    }
                                }
                            }


                            break;

                        case "OpenWithProgids":
                            foreach (var proIdValue in subKey.Values)
                            {
                                op.Add(proIdValue.ValueName);
                            }
                            break;

                        case "UserChoice":
                            var progId = subKey.Values.SingleOrDefault(t => t.ValueName == "ProgId");
                            if (progId != null)
                            {
                                uc = progId.ValueData;
                            }
                            break;
                        }
                    }

                    //we have enough to add an entry

                    var vo = new ValuesOut(registryKey.KeyName, string.Join(", ", oe), string.Join(", ", op), uc);
                    vo.BatchKeyPath   = key.KeyPath;
                    vo.BatchValueName = "Multiple";

                    _values.Add(vo);
                }
            }
            catch (Exception ex)
            {
                Errors.Add($"Error processing FileExts subkey {currentKey}: {ex.Message}");
            }

            if (Errors.Count > 0)
            {
                AlertMessage = "Errors detected. See Errors information in lower right corner of plugin window";
            }
        }
        public void ProcessValues(RegistryKey key)
        {
            _values.Clear();
            Errors.Clear();

            var currentKey = string.Empty;

            try
            {
                foreach (var registryKey in key.SubKeys) // subkeys of FileExts
                {
                    currentKey = registryKey.KeyName;

                    var oe = new List<string>();
                    var op = new List<string>();
                    var uc = "(UserChoice key not present)";

                    if (registryKey.SubKeys.Count == 0)
                    {
                        var progId = registryKey.Values.SingleOrDefault(t => t.ValueName == "Progid");
                        if (progId != null)
                        {
                            op.Add(progId.ValueData);
                        }
                        var vo1 = new ValuesOut(registryKey.KeyName, string.Join(", ", oe), string.Join(", ", op), uc);

                        _values.Add(vo1);
                        continue;
                    }

                    foreach (var subKey in registryKey.SubKeys) // subkey's subkeys
                    {
                        switch (subKey.KeyName)
                        {
                            case "OpenWithList":
                                // contains values with name == char and value data of an executable name
                                //there is an MRUList that contains the order the executables were selected

                                var mruList = subKey.Values.SingleOrDefault(t => t.ValueName == "MRUList");

                                if (mruList != null)
                                {
                                    //foreach slot in MRU, get the value and append it to our oe variable

                                    foreach (var mruPos in mruList.ValueData.ToCharArray())
                                    {
                                        var exeName =
                                            subKey.Values.SingleOrDefault(t => t.ValueName == mruPos.ToString());

                                        if (exeName != null)
                                        {
                                            oe.Add(exeName.ValueData);
                                        }
                                        else
                                        {
                                            oe.Add($"(Executable name for MRU slot '{mruPos}' not found!)");
                                        }
                                    }
                                }

                                break;
                            case "OpenWithProgids":
                                foreach (var proIdValue in subKey.Values)
                                {
                                    op.Add(proIdValue.ValueName);
                                }
                                break;
                            case "UserChoice":
                                var progId = subKey.Values.SingleOrDefault(t => t.ValueName == "ProgId");
                                if (progId != null)
                                {
                                    uc = progId.ValueData;
                                }
                                break;
                        }
                    }

                    //we have enough to add an entry

                    var vo = new ValuesOut(registryKey.KeyName, string.Join(", ", oe), string.Join(", ", op), uc);

                    _values.Add(vo);
                }
            }
            catch (Exception ex)
            {
                Errors.Add($"Error processing FileExts subkey {currentKey}: {ex.Message}");
            }

            if (Errors.Count > 0)
            {
                AlertMessage = "Errors detected. See Errors information in lower right corner of plugin window";
            }
        }