コード例 #1
0
        private RegistryExplorer.Registry.RegSearchArgs GetSearchArgs(Microsoft.Win32.RegistryKey[] keys)
        {
            RegistryExplorer.Registry.RegSearchLookAt lookAt     = GetSearchTarget();
            RegistryExplorer.Registry.RegSearchArgs   searchArgs =
                new RegistryExplorer.Registry.RegSearchArgs(keys, txtPattern.Text, chkMatchCase.Checked, lookAt, chkUseRegex.Checked);

            return(searchArgs);
        }
コード例 #2
0
        private void btnFind_Click(object sender, System.EventArgs e)
        {
            if (btnFind.Text == "F&ind")
            {
                Microsoft.Win32.RegistryKey[] keys;

                if (cmbSearch.Text == "All Hives")
                {
                    keys = new Microsoft.Win32.RegistryKey[cmbSearch.Items.Count];
                    for (int i = 0; i < cmbSearch.Items.Count; i++)
                    {
                        keys[i] = RegistryExplorer.Registry.RegUtility.ParseRootKey(cmbSearch.Items[i].ToString());
                    }
                }
                else
                {
                    keys = new Microsoft.Win32.RegistryKey[] {
                        RegistryExplorer.Registry.RegUtility.ParseRootKey(cmbSearch.Text)
                    }
                };

                if (txtBranch.Text != string.Empty)
                {
                    keys[0] = keys[0].OpenSubKey(txtBranch.Text);
                    if (keys[0] == null)
                    {
                        UIUtility.DisplayError(this, RegistryExplorer.Properties.Resources.Error_InvalidKey, txtBranch);
                        return;
                    }
                }

                RegistryExplorer.Registry.RegSearchArgs searchArgs = GetSearchArgs(keys);
                StartSearch();
                try
                {
                    searcher.Start(searchArgs);
                }
                catch (System.ArgumentException ex)
                {
                    toolStripStatusLabel1.Text = "Ready.";
                    UIUtility.DisplayError(this, ex.Message, txtPattern);
                    EnableSearch();
                    return;
                }
                searchStarted = true;
            }
            else
            {
                btnFind.Enabled = false;
                searcher.Stop();
            }
        }