private void DiscoverGeckosInRegistry()
        {
            try
            {
                RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"Software\Mozilla", false);
                if (rk != null)
                {
                    using (var rkc = new RegistryKeyChain(rk))
                        WalkRegistryKey(rkc);
                    rk.Close();
                }
            } catch {}

            try
            {
                RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Mozilla", false);
                if (rk != null)
                {
                    using (var rkc = new RegistryKeyChain(rk))
                        WalkRegistryKey(rkc);
                    rk.Close();
                }
            }
            catch { }
        }
        private void WalkRegistryKey(RegistryKeyChain key)
        {
            try
            {
                string path = null, version = null, appname = null;
                path = key.Value("Install Directory");
                if (path == null)
                {
                    string exe = key.Value("PathToExe");
                    if (exe != null)
                    {
                        path = Path.GetDirectoryName(exe.Trim());
                    }
                }
                if (path != null)
                {
                    path = Path.GetFullPath(path.Trim());
                }
                if (path != null && IsGeckoPathKnown(path))
                {
                    path = null;
                }
                // try to detect gecko version from this or parent key
                if (path != null)
                {
                    version = key.Value("GeckoVer");
                    appname = key.RootName;

                    if (version == null && key.Is("bin") && key.Parent != null)
                    {
                        version = key.Parent.Value("GeckoVer");
                        appname = key.Parent.Name;
                    }
                    if (version == null && key.Is("Main") && key.Parent != null && key.Parent.Parent != null)
                    {
                        version = key.Parent.Parent.Value(null);
                        appname = String.Format("{0} {1}", key.Parent.Parent.Name, key.Parent.Name);
                    }
                }
                if (path != null)
                {
                    GeckoAppInfo gai = new GeckoAppInfo(path, version, appname)
                    {
                        IsAutoDiscovered = true
                    };
                    geckos.Add(gai);
                }
            } catch {}

            string[] skeys = key.Subkeys;
            Array.ForEach(skeys, sk =>
            {
                try
                {
                    using (RegistryKeyChain rsk = key.Subkey(sk))
                    {
                        if (rsk != null)
                        {
                            WalkRegistryKey(rsk);
                        }
                    }
                }
                catch
                {
                }
            });
        }
 private RegistryKeyChain(RegistryKey key, RegistryKeyChain chain)
 {
     rk     = key;
     parent = chain;
 }