// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+#if !NET_2_1
+
using System;
+using System.Runtime.InteropServices;
namespace Microsoft.Win32
{
- public
-#if NET_2_0
- static
-#else
- sealed
-#endif
- class Registry
+ [ComVisible (true)]
+ public static class Registry
{
-#if !NET_2_0
- private Registry () { }
-#endif
public static readonly RegistryKey ClassesRoot = new RegistryKey (
- RegistryHive.ClassesRoot, "HKEY_CLASSES_ROOT");
+ RegistryHive.ClassesRoot);
public static readonly RegistryKey CurrentConfig = new RegistryKey (
- RegistryHive.CurrentConfig, "HKEY_CURRENT_CONFIG");
+ RegistryHive.CurrentConfig);
public static readonly RegistryKey CurrentUser = new RegistryKey (
- RegistryHive.CurrentUser, "HKEY_CURRENT_USER");
+ RegistryHive.CurrentUser);
+
+ [Obsolete ("Use PerformanceData instead")]
public static readonly RegistryKey DynData = new RegistryKey (
- RegistryHive.DynData, "HKEY_DYN_DATA");
+ RegistryHive.DynData);
public static readonly RegistryKey LocalMachine = new RegistryKey (
- RegistryHive.LocalMachine, "HKEY_LOCAL_MACHINE");
+ RegistryHive.LocalMachine);
public static readonly RegistryKey PerformanceData = new RegistryKey (
- RegistryHive.PerformanceData, "HKEY_PERFORMANCE_DATA");
+ RegistryHive.PerformanceData);
public static readonly RegistryKey Users = new RegistryKey (
- RegistryHive.Users, "HKEY_USERS");
+ RegistryHive.Users);
-#if NET_2_0
static RegistryKey ToKey (string keyName, bool setting)
{
if (keyName == null)
key.SetValue (valueName, value);
}
+
+ public static void SetValue (string keyName, string valueName, object value, RegistryValueKind valueKind)
+ {
+ RegistryKey key = ToKey (keyName, true);
+ if (valueName.Length > 255)
+ throw new ArgumentException ("valueName is larger than 255 characters", "valueName");
+
+ if (key == null)
+ throw new ArgumentException ("cant locate that keyName", "keyName");
+
+ key.SetValue (valueName, value, valueKind);
+ }
public static object GetValue (string keyName, string valueName, object defaultValue)
{
return key.GetValue (valueName, defaultValue);
}
-#endif
}
}
+
+#endif // NET_2_1
+