private void txtPath_Leave(object sender, EventArgs e)
 {
     if (txtPath.Text.Length > 0 && txtPath.Text.ToUpper().StartsWith("HKEY_"))
     {
         string[] parts = txtPath.Text.Split('\\');
         if (parts.Length > 1)
         {
             Microsoft.Win32.RegistryHive rh = RegistryQueryCollectorConfigEntry.GetRegistryHiveFromString(parts[0]);
             cboRegistryHive.Text = rh.ToString();
             txtPath.Text         = txtPath.Text.Substring(parts[0].Length + 1);
         }
     }
 }
Beispiel #2
0
        } // End Function RecursivelyListKeys

        public static string ToHiveName(Microsoft.Win32.RegistryHive regHive)
        {
            switch (regHive)
            {
            case Microsoft.Win32.RegistryHive.CurrentUser:
                return("HKEY_CURRENT_USER");

            case Microsoft.Win32.RegistryHive.LocalMachine:
                return("HKEY_LOCAL_MACHINE");

            case Microsoft.Win32.RegistryHive.PerformanceData:
                return("HKEY_PERFORMANCE_DATA");

            case Microsoft.Win32.RegistryHive.Users:
                return("HKEY_USERS");

            case Microsoft.Win32.RegistryHive.ClassesRoot:
                return("HKEY_CLASSES_ROOT");

            case Microsoft.Win32.RegistryHive.CurrentConfig:
                return("HKEY_CURRENT_CONFIG");
                // case Microsoft.Win32.RegistryHive.DynData: return "HKEY_DYN_DATA";

                // default: return regHive.ToString();
            } // End switch (regHive)

            string hiveName = regHive.ToString();

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("HKEY");

            foreach (char c in hiveName)
            {
                if (char.IsUpper(c))
                {
                    sb.Append("_");
                }

                sb.Append(c);
            } // Next c

            hiveName = sb.ToString().ToUpper();
            sb.Clear();
            sb = null;

            return(hiveName);
        } // End Function ToHiveName