+2009-11-21 Miguel de Icaza <miguel@novell.com>
+
+ * RegistryKey.cs: Implement a GetValueKind and a handful of
+ methods.
+
2009-04-25 Sebastien Pouliot <sebastien@ximian.com>
* *.cs: Exclude the files for the NET_2_1 profile, since they are
void Close (RegistryKey rkey);
object GetValue (RegistryKey rkey, string name, object default_value, RegistryValueOptions options);
+ RegistryValueKind GetValueKind (RegistryKey rkey, string name);
void SetValue (RegistryKey rkey, string name, object value);
int SubKeyCount (RegistryKey rkey);
RegistryHive.CurrentConfig);
public static readonly RegistryKey CurrentUser = new RegistryKey (
RegistryHive.CurrentUser);
+
+ [Obsolete ("Use PerformanceData instead")]
public static readonly RegistryKey DynData = new RegistryKey (
RegistryHive.DynData);
public static readonly RegistryKey LocalMachine = new RegistryKey (
[ComVisible (false)]
public RegistryValueKind GetValueKind (string name)
{
- throw new NotImplementedException ();
+ return RegistryApi.GetValueKind (this, name);
}
/// <summary>
}
[ComVisible (false)]
+ [MonoLimitation ("permissionCheck is ignored in Mono")]
public RegistryKey CreateSubKey (string subkey, RegistryKeyPermissionCheck permissionCheck)
{
- throw new NotImplementedException ();
+ return CreateSubKey (subkey);
}
[ComVisible (false)]
+ [MonoLimitation ("permissionCheck and registrySecurity are ignored in Mono")]
public RegistryKey CreateSubKey (string subkey, RegistryKeyPermissionCheck permissionCheck, RegistrySecurity registrySecurity)
{
- throw new NotImplementedException ();
+ return CreateSubKey (subkey);
}
/// <summary>
}
[ComVisible (false)]
+ [MonoLimitation ("permissionCheck is ignored in Mono")]
public RegistryKey OpenSubKey (string name, RegistryKeyPermissionCheck permissionCheck)
{
- throw new NotImplementedException ();
+ return OpenSubKey (name);
}
[ComVisible (false)]
+ [MonoLimitation ("permissionCheck and rights are ignored in Mono")]
public RegistryKey OpenSubKey (string name, RegistryKeyPermissionCheck permissionCheck, RegistryRights rights)
{
- throw new NotImplementedException ();
+ return OpenSubKey (name);
}
public void SetAccessControl (RegistrySecurity registrySecurity)
}
}
+ public RegistryValueKind GetValueKind (string name)
+ {
+ if (name == null)
+ return RegistryValueKind.Unknown;
+ object value = values [name];
+ if (value == null)
+ return RegistryValueKind.Unknown;
+
+ if (value is int)
+ return RegistryValueKind.DWord;
+ if (value is string [])
+ return RegistryValueKind.MultiString;
+ if (value is long)
+ return RegistryValueKind.QWord;
+ if (value is byte [])
+ return RegistryValueKind.Binary;
+ if (value is string)
+ return RegistryValueKind.String;
+ if (value is ExpandString)
+ return RegistryValueKind.ExpandString;
+ return RegistryValueKind.Unknown;
+ }
+
public object GetValue (string name, RegistryValueOptions options)
{
if (IsMarkedForDeletion)
throw RegistryKey.CreateMarkedForDeletionException ();
return self.Ensure (rkey, ToUnix (keyname), writable);
}
+
+ public RegistryValueKind GetValueKind (RegistryKey rkey, string name)
+ {
+ KeyHandler self = KeyHandler.Lookup (rkey, true);
+ if (self != null)
+ return self.GetValueKind (name);
+
+ // key was removed since it was opened or it does not exist.
+ return RegistryValueKind.Unknown;
+ }
+
}
}
return key.Handle != null;
}
+ public RegistryValueKind GetValueKind (RegistryKey rkey, string name)
+ {
+ 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 RegistryValueKind.Unknown;
+
+ return type;
+ }
+
/// <summary>
/// Acctually read a registry value. Requires knowledge of the
/// value's type and size.