/// <inheritdoc /> public object GetValue(string name, object defaultValue, RegistryValueOptions options) { // Coerce null into the empty string (i.e. '(Default)' value in the registry). var valueName = name ?? string.Empty; return(_values.TryGetValue(valueName, out var value) ? value : defaultValue); }
public object GetValue(string name, RegistryValueOptions options) { if (IsMarkedForDeletion) { return(null); } if (name == null) { name = string.Empty; } object value; lock (values) value = values [name]; ExpandString exp = value as ExpandString; if (exp == null) { return(value); } if ((options & RegistryValueOptions.DoNotExpandEnvironmentNames) == 0) { return(exp.Expand()); } return(exp.ToString()); }
public void GetExpandableStringValue(string testValue, string expectedValue, RegistryValueOptions getOptions) { const string valueName = "MyTestKey"; TestRegistryKey.SetValue(valueName, testValue, RegistryValueKind.ExpandString); Assert.Equal(expectedValue, TestRegistryKey.GetValue(valueName, null, getOptions).ToString()); TestRegistryKey.DeleteValue(valueName); }
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { if (options < RegistryValueOptions.None || options > RegistryValueOptions.DoNotExpandEnvironmentNames) { throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)options), nameof(options)); } bool doNotExpand = (options == RegistryValueOptions.DoNotExpandEnvironmentNames); return InternalGetValue(name, defaultValue, doNotExpand, checkSecurity: true); }
public Object GetValue(String name, Object defaultValue, RegistryValueOptions options) { if (options < RegistryValueOptions.None || options > RegistryValueOptions.DoNotExpandEnvironmentNames) { throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)options), nameof(options)); } bool doNotExpand = (options == RegistryValueOptions.DoNotExpandEnvironmentNames); CheckPermission(RegistryInternalCheck.CheckValueReadPermission, name, false, RegistryKeyPermissionCheck.Default); return(InternalGetValue(name, defaultValue, doNotExpand, true)); }
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { if ((options < RegistryValueOptions.None) || (options > RegistryValueOptions.DoNotExpandEnvironmentNames)) { string format = RegistryProviderStrings.Arg_EnumIllegalVal; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, format, new object[] { options.ToString() })); } bool doNotExpand = options == RegistryValueOptions.DoNotExpandEnvironmentNames; this.CheckValueReadPermission(name); return(this.InternalGetValue(name, defaultValue, doNotExpand, true)); }
public Registry GetValueRequest(String name, out Object returnValue, Object defaultValue = null, RegistryValueOptions registryValueOptions = RegistryValueOptions.None, Boolean isThrow = false) { if (!_allowRequest) { returnValue = defaultValue; return(this); } returnValue = GetValue(name, defaultValue, registryValueOptions, isThrow); return(this); }
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { object obj2 = this.regKey.GetValue(name, defaultValue, options); try { obj2 = RegistryWrapperUtils.ConvertValueToUIntFromRegistryIfNeeded(name, obj2, this.GetValueKind(name)); } catch (IOException) { } return obj2; }
/// Get registry value, or return default value with support for 32 and 64 bit registries public static object RegistryGet(string keyAndValue, object def, RegistryValueOptions options) { if (keyAndValue == null) throw new ArgumentNullException("keyAndValue"); using (RegW64Helper rn = new RegW64Helper(keyAndValue)) { using (var rk = rn.Open(false)) { if (rk == null) return def; return rk.GetValue(rn.ValueName, def, options); } } }
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { object obj2 = this.regKey.GetValue(name, defaultValue, options); try { obj2 = RegistryWrapperUtils.ConvertValueToUIntFromRegistryIfNeeded(name, obj2, this.GetValueKind(name)); } catch (IOException) { } return(obj2); }
public object GetValue(RegistryKey rkey, string name, object default_value, RegistryValueOptions options) { KeyHandler keyHandler = KeyHandler.Lookup(rkey, true); if (keyHandler == null) { return(default_value); } if (keyHandler.ValueExists(name)) { return(keyHandler.GetValue(name, options)); } return(default_value); }
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { object value = _regKey.GetValue(name, defaultValue, options); try { value = RegistryWrapperUtils.ConvertValueToUIntFromRegistryIfNeeded(name, value, GetValueKind(name)); } catch (System.IO.IOException) { // This is expected if the value does not exist. } return(value); }
/// <summary> /// Gets a named value stored within this key. /// </summary> /// <param name="name">The name of the value to retrieve.</param> /// <param name="defaultValue">The default value to return, if no existing value is stored.</param> /// <param name="options">Flags controlling how the value is processed before it's returned.</param> /// <returns>The value as a .NET object.</returns> /// <remarks>The mapping from registry type of .NET type is as follows: /// <list type="table"> /// <listheader> /// <term>Value Type</term> /// <term>.NET type</term> /// </listheader> /// <item> /// <description>String</description> /// <description>string</description> /// </item> /// <item> /// <description>ExpandString</description> /// <description>string</description> /// </item> /// <item> /// <description>Link</description> /// <description>string</description> /// </item> /// <item> /// <description>DWord</description> /// <description>uint</description> /// </item> /// <item> /// <description>DWordBigEndian</description> /// <description>uint</description> /// </item> /// <item> /// <description>MultiString</description> /// <description>string[]</description> /// </item> /// <item> /// <description>QWord</description> /// <description>ulong</description> /// </item> /// </list> /// </remarks> public object GetValue(string name, object defaultValue, RegistryValueOptions options) { RegistryValue regVal = GetRegistryValue(name); if (regVal != null) { if (regVal.DataType == RegistryValueType.ExpandString && (options & RegistryValueOptions.DoNotExpandEnvironmentNames) == 0) { return(Environment.ExpandEnvironmentVariables((string)regVal.Value)); } return(regVal.Value); } return(defaultValue); }
public object GetValue(RegistryKey rkey, string name, object default_value, RegistryValueOptions options) { KeyHandler self = KeyHandler.Lookup(rkey, true); if (self == null) { // key was removed since it was opened return(default_value); } if (self.ValueExists(name)) { return(self.GetValue(name, options)); } return(default_value); }
public Object GetValue(String name, Object defaultValue = null, RegistryValueOptions registryValueOptions = RegistryValueOptions.None, Boolean isThrow = false) { try { return(_registryKey?.GetValue(name, defaultValue, registryValueOptions)); } catch (Exception) { if (isThrow) { throw; } } return(null); }
/// Get registry value, or return default value with support for 32 and 64 bit registries public static object RegistryGet(string keyAndValue, object def, RegistryValueOptions options) { if (keyAndValue == null) { throw new ArgumentNullException("keyAndValue"); } using (RegW64Helper rn = new RegW64Helper(keyAndValue)) { using (var rk = rn.Open(false)) { if (rk == null) { return(def); } return(rk.GetValue(rn.ValueName, def, options)); } } }
/// <summary>Method for getting the basekey + subkeys from the path input as a Dictionary.</summary> internal static RegistryProperty[] GetRegistryProperty(RegistryKey regKey, RegistryValueOptions valueOptions, bool includeValueKind) { string[] valueNames = regKey.GetValueNames(); RegistryValueKind valueKind = RegistryValueKind.Unknown; RegistryProperty[] returnData = new RegistryProperty[valueNames.Length]; for (int i = 0; i < valueNames.Length; i++) { object value = regKey.GetValue(valueNames[i], null, valueOptions); if (includeValueKind) { valueKind = regKey.GetValueKind(valueNames[i]); } returnData[i] = new RegistryProperty() { Name = valueNames[i], ValueKind = valueKind, Value = value }; } return(returnData); }
public object GetValue(string name, RegistryValueOptions options) { if (this.IsMarkedForDeletion) { return(null); } if (name == null) { name = string.Empty; } object obj = this.values[name]; ExpandString expandString = obj as ExpandString; if (expandString == null) { return(obj); } if ((options & RegistryValueOptions.DoNotExpandEnvironmentNames) == RegistryValueOptions.None) { return(expandString.Expand()); } return(expandString.ToString()); }
/// <inheritdoc /> public object GetValue(string name, object defaultValue, RegistryValueOptions options) { return(_registryKey.GetValue(name, defaultValue, options)); }
public Object GetValue(String name, Object defaultValue, RegistryValueOptions options) { // TODO return GetValue(name, defaultValue); }
/// <summary> /// TODO: Add Comment /// </summary> /// <param name="name"></param> /// <param name="defaultValue"></param> /// <param name="options"></param> /// <returns></returns> public object GetValue(string name, object defaultValue, RegistryValueOptions options) { return RegistryKeyInstance.GetValue(name, defaultValue, options); }
public Object GetValue(String name, Object defaultValue, RegistryValueOptions options) { // TODO return(GetValue(name, defaultValue)); }
/// <summary> /// Acctually read a registry value. Requires knowledge of the /// value's type and size. /// </summary> public object GetValue(RegistryKey rkey, string name, object defaultValue, RegistryValueOptions options) { RegistryValueKind type = 0; int size = 0; object obj = null; IntPtr handle = GetHandle(rkey); int result = RegQueryValueEx(handle, name, IntPtr.Zero, ref type, IntPtr.Zero, ref size); if (result == Win32ResultCode.FileNotFound || result == Win32ResultCode.MarkedForDeletion) { return(defaultValue); } if (result != Win32ResultCode.MoreData && result != Win32ResultCode.Success) { GenerateException(result); } if (type == RegistryValueKind.String) { byte[] data; result = GetBinaryValue(rkey, name, type, out data, size); obj = RegistryKey.DecodeString(data); } else if (type == RegistryValueKind.ExpandString) { byte [] data; result = GetBinaryValue(rkey, name, type, out data, size); obj = RegistryKey.DecodeString(data); if ((options & RegistryValueOptions.DoNotExpandEnvironmentNames) == 0) { obj = Environment.ExpandEnvironmentVariables((string)obj); } } else if (type == RegistryValueKind.DWord) { int data = 0; result = RegQueryValueEx(handle, name, IntPtr.Zero, ref type, ref data, ref size); obj = data; } else if (type == RegistryValueKind.QWord) { long data = 0; result = RegQueryValueEx(handle, name, IntPtr.Zero, ref type, ref data, ref size); obj = data; } else if (type == RegistryValueKind.Binary) { byte[] data; result = GetBinaryValue(rkey, name, type, out data, size); obj = data; } else if (type == RegistryValueKind.MultiString) { obj = null; byte[] data; result = GetBinaryValue(rkey, name, type, out data, size); if (result == Win32ResultCode.Success) { obj = RegistryKey.DecodeString(data).Split('\0'); } } else { // should never get here throw new SystemException(); } // check result codes again: if (result != Win32ResultCode.Success) { GenerateException(result); } return(obj); }
public object GetValue (string name, RegistryValueOptions options) { if (IsMarkedForDeletion) return null; if (name == null) name = string.Empty; object value = values [name]; ExpandString exp = value as ExpandString; if (exp == null) return value; if ((options & RegistryValueOptions.DoNotExpandEnvironmentNames) == 0) return exp.Expand (); return exp.ToString (); }
public object GetValue(RegistryKey rkey, string name, object defaultValue, RegistryValueOptions options) { RegistryValueKind registryValueKind = RegistryValueKind.Unknown; int size = 0; IntPtr handle = Win32RegistryApi.GetHandle(rkey); int num = Win32RegistryApi.RegQueryValueEx(handle, name, IntPtr.Zero, ref registryValueKind, IntPtr.Zero, ref size); if (num == 2 || num == 1018) { return(defaultValue); } if (num != 234 && num != 0) { this.GenerateException(num); } object obj; if (registryValueKind == RegistryValueKind.String) { byte[] data; num = this.GetBinaryValue(rkey, name, registryValueKind, out data, size); obj = RegistryKey.DecodeString(data); } else if (registryValueKind == RegistryValueKind.ExpandString) { byte[] data2; num = this.GetBinaryValue(rkey, name, registryValueKind, out data2, size); obj = RegistryKey.DecodeString(data2); if ((options & RegistryValueOptions.DoNotExpandEnvironmentNames) == RegistryValueOptions.None) { obj = Environment.ExpandEnvironmentVariables((string)obj); } } else if (registryValueKind == RegistryValueKind.DWord) { int num2 = 0; num = Win32RegistryApi.RegQueryValueEx(handle, name, IntPtr.Zero, ref registryValueKind, ref num2, ref size); obj = num2; } else if (registryValueKind == RegistryValueKind.Binary) { byte[] array; num = this.GetBinaryValue(rkey, name, registryValueKind, out array, size); obj = array; } else { if (registryValueKind != RegistryValueKind.MultiString) { throw new SystemException(); } obj = null; byte[] data3; num = this.GetBinaryValue(rkey, name, registryValueKind, out data3, size); if (num == 0) { obj = RegistryKey.DecodeString(data3).Split(new char[1]); } } if (num != 0) { this.GenerateException(num); } return(obj); }
public Object GetValue(string name, Object defaultValue, RegistryValueOptions options) { return default(Object); }
public object GetValue(string name, RegistryValueOptions options) { return(RegistrySubKey.GetValue(name, null, options)); }
public Object GetValue(string name, Object defaultValue, RegistryValueOptions options) { return(default(Object)); }
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { throw new PlatformNotSupportedException(); }
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { return _underlyingObject.GetValue(name, defaultValue, options); }
/// <summary> /// Retrieve a value by its name. /// </summary> /// <param name="key">Value name</param> /// <param name="defaultValue">Default value incase of failure in retrieval</param> /// <param name="options">Additional options</param> public static object retrieve(string key, object defaultValue = null, RegistryValueOptions options = RegistryValueOptions.None) { return(Root.GetValue(key, defaultValue, options)); }
public object GetValue(string name, object defaultValue, RegistryValueOptions options);
public Object GetValue(String name, Object defaultValue, RegistryValueOptions options) { if( options < RegistryValueOptions.None || options > RegistryValueOptions.DoNotExpandEnvironmentNames) { throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)options), "options"); } bool doNotExpand = (options == RegistryValueOptions.DoNotExpandEnvironmentNames); CheckPermission(RegistryInternalCheck.CheckValueReadPermission, name, false, RegistryKeyPermissionCheck.Default); return InternalGetValue(name, defaultValue, doNotExpand, true); }
public object GetValue (RegistryKey rkey, string name, object default_value, RegistryValueOptions options) { KeyHandler self = KeyHandler.Lookup (rkey, true); if (self == null) { // key was removed since it was opened return default_value; } if (self.ValueExists (name)) return self.GetValue (name, options); return default_value; }
public object GetValue (string name, object defaultValue, RegistryValueOptions options) { AssertKeyStillValid (); return RegistryApi.GetValue (this, name, defaultValue, options); }
public object GetValue (string name, object defaultValue, RegistryValueOptions options) { throw new PlatformNotSupportedException (); }
/// <summary> /// This function will read the key in the given registry path and returns the value to it. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key">Registry key</param> /// <param name="path">Path</param> /// <param name="value">The value.</param> /// <param name="kind">The kind.</param> /// <param name="options">The options.</param> /// <param name="registryView">The registry view.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public static bool TryGetValue <T>(string key, string path, out T value, RegistryValueKind kind, RegistryValueOptions options = RegistryValueOptions.None, RegistryView registryView = RegistryView.Default) { var success = true; value = default(T); try { using (var view = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, registryView)) { using (var registryKey = view.OpenSubKey(path)) { if (registryKey != null) { object registryValue = registryKey.GetValue(key, null, options); if (registryValue != null) { value = (T)Convert.ChangeType(registryValue, typeof(T)); } else { success = false; } } else { success = false; } } } } catch (Exception) { value = default(T); success = false; } return(success); }
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { using (this.provider.CurrentPSTransaction) return(this.txRegKey.GetValue(name, defaultValue, options)); }
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { using (_provider.CurrentPSTransaction) { object value = _txRegKey.GetValue(name, defaultValue, options); try { value = RegistryWrapperUtils.ConvertValueToUIntFromRegistryIfNeeded(name, value, GetValueKind(name)); } catch (System.IO.IOException) { // This is expected if the value does not exist. } return value; } }
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { throw new NotImplementedException("GetValue(string name, object defaultValue, RegistryValueOptions options) is not implemented. TransactedRegistry related APIs should not be used."); }
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { throw new NotImplementedException(); }
public abstract object GetValue(string name, object defaultValue, RegistryValueOptions options);
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { AssertKeyStillValid(); return(RegistryApi.GetValue(this, name, defaultValue, options)); }
/// <summary> /// Acctually read a registry value. Requires knowledge of the /// value's type and size. /// </summary> public object GetValue (RegistryKey rkey, string name, object defaultValue, RegistryValueOptions options) { RegistryValueKind type = 0; int size = 0; object obj = null; IntPtr handle = GetHandle (rkey); int result = RegQueryValueEx (handle, name, IntPtr.Zero, ref type, IntPtr.Zero, ref size); if (result == Win32ResultCode.FileNotFound || result == Win32ResultCode.MarkedForDeletion) { return defaultValue; } if (result != Win32ResultCode.MoreData && result != Win32ResultCode.Success ) { GenerateException (result); } if (type == RegistryValueKind.String) { byte[] data; result = GetBinaryValue (rkey, name, type, out data, size); obj = RegistryKey.DecodeString (data); } else if (type == RegistryValueKind.ExpandString) { byte [] data; result = GetBinaryValue (rkey, name, type, out data, size); obj = RegistryKey.DecodeString (data); if ((options & RegistryValueOptions.DoNotExpandEnvironmentNames) == 0) obj = Environment.ExpandEnvironmentVariables ((string) obj); } else if (type == RegistryValueKind.DWord) { int data = 0; result = RegQueryValueEx (handle, name, IntPtr.Zero, ref type, ref data, ref size); obj = data; } else if (type == RegistryValueKind.QWord) { long data = 0; result = RegQueryValueEx (handle, name, IntPtr.Zero, ref type, ref data, ref size); obj = data; } else if (type == RegistryValueKind.Binary) { byte[] data; result = GetBinaryValue (rkey, name, type, out data, size); obj = data; } else if (type == RegistryValueKind.MultiString) { obj = null; byte[] data; result = GetBinaryValue (rkey, name, type, out data, size); if (result == Win32ResultCode.Success) obj = RegistryKey.DecodeString (data).Split ('\0'); } else { // should never get here throw new SystemException (); } // check result codes again: if (result != Win32ResultCode.Success) { GenerateException (result); } return obj; }
public Object GetValue(String name, Object defaultValue, RegistryValueOptions options) { if (options < RegistryValueOptions.None || options > RegistryValueOptions.DoNotExpandEnvironmentNames) { string resourceTemplate = RegistryProviderStrings.Arg_EnumIllegalVal; string resource = String.Format(CultureInfo.CurrentCulture, resourceTemplate, options.ToString()); throw new ArgumentException(resource); } bool doNotExpand = (options == RegistryValueOptions.DoNotExpandEnvironmentNames); CheckValueReadPermission(name); return InternalGetValue(name, defaultValue, doNotExpand, true); }
public object GetValue(string name, object defaultValue, RegistryValueOptions options) { if ((options < RegistryValueOptions.None) || (options > RegistryValueOptions.DoNotExpandEnvironmentNames)) { string format = RegistryProviderStrings.Arg_EnumIllegalVal; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, format, new object[] { options.ToString() })); } bool doNotExpand = options == RegistryValueOptions.DoNotExpandEnvironmentNames; this.CheckValueReadPermission(name); return this.InternalGetValue(name, defaultValue, doNotExpand, true); }