Example #1
0
        public static void SetValue(string keyName, string valueName, object value, RegistryValueKind valueKind)
        {
            string      subKeyName;
            RegistryKey subKey = Registry.GetBaseKeyFromKeyName(keyName, out subKeyName).CreateSubKey(subKeyName);

            try
            {
                subKey.SetValue(valueName, value, valueKind);
            }
            finally
            {
                subKey.Close();
            }
        }
Example #2
0
        public static object GetValue(string keyName, string valueName, object defaultValue)
        {
            string      subKeyName;
            RegistryKey registryKey = Registry.GetBaseKeyFromKeyName(keyName, out subKeyName).OpenSubKey(subKeyName);

            if (registryKey == null)
            {
                return((object)null);
            }
            try
            {
                return(registryKey.GetValue(valueName, defaultValue));
            }
            finally
            {
                registryKey.Close();
            }
        }
        public static object GetValue(string keyName, string valueName, object defaultValue)
        {
            string      name;
            RegistryKey baseKeyFromKeyName = Registry.GetBaseKeyFromKeyName(keyName, out name);
            RegistryKey registryKey        = baseKeyFromKeyName.OpenSubKey(name);

            if (registryKey == null)
            {
                return(null);
            }
            object value;

            try
            {
                value = registryKey.GetValue(valueName, defaultValue);
            }
            finally
            {
                registryKey.Close();
            }
            return(value);
        }