diff options
Diffstat (limited to 'src/System.Private.CoreLib/shared/Microsoft')
8 files changed, 10 insertions, 213 deletions
diff --git a/src/System.Private.CoreLib/shared/Microsoft/Win32/Registry.cs b/src/System.Private.CoreLib/shared/Microsoft/Win32/Registry.cs deleted file mode 100644 index d9b1d9dd08..0000000000 --- a/src/System.Private.CoreLib/shared/Microsoft/Win32/Registry.cs +++ /dev/null @@ -1,106 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace Microsoft.Win32 -{ - /// <summary>Registry encapsulation. Contains members representing all top level system keys.</summary> -#if REGISTRY_ASSEMBLY - public -#else - internal -#endif - static class Registry - { - /// <summary>Current User Key. This key should be used as the root for all user specific settings.</summary> - public static readonly RegistryKey CurrentUser = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default); - - /// <summary>Local Machine key. This key should be used as the root for all machine specific settings.</summary> - public static readonly RegistryKey LocalMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default); - -#if REGISTRY_ASSEMBLY - /// <summary>Classes Root Key. This is the root key of class information.</summary> - public static readonly RegistryKey ClassesRoot = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Default); - - /// <summary>Users Root Key. This is the root of users.</summary> - public static readonly RegistryKey Users = RegistryKey.OpenBaseKey(RegistryHive.Users, RegistryView.Default); - - /// <summary>Performance Root Key. This is where dynamic performance data is stored on NT.</summary> - public static readonly RegistryKey PerformanceData = RegistryKey.OpenBaseKey(RegistryHive.PerformanceData, RegistryView.Default); - - /// <summary>Current Config Root Key. This is where current configuration information is stored.</summary> - public static readonly RegistryKey CurrentConfig = RegistryKey.OpenBaseKey(RegistryHive.CurrentConfig, RegistryView.Default); - - /// <summary> - /// Parse a keyName and returns the basekey for it. - /// It will also store the subkey name in the out parameter. - /// If the keyName is not valid, we will throw ArgumentException. - /// The return value shouldn't be null. - /// </summary> - private static RegistryKey GetBaseKeyFromKeyName(string keyName, out string subKeyName) - { - if (keyName == null) - { - throw new ArgumentNullException(nameof(keyName)); - } - - int i = keyName.IndexOf('\\'); - int length = i != -1 ? i : keyName.Length; - - // Determine the potential base key from the length. - RegistryKey baseKey = null; - switch (length) - { - case 10: baseKey = Users; break; // HKEY_USERS - case 17: baseKey = char.ToUpperInvariant(keyName[6]) == 'L' ? ClassesRoot : CurrentUser; break; // HKEY_C[L]ASSES_ROOT, otherwise HKEY_CURRENT_USER - case 18: baseKey = LocalMachine; break; // HKEY_LOCAL_MACHINE - case 19: baseKey = CurrentConfig; break; // HKEY_CURRENT_CONFIG - case 21: baseKey = PerformanceData; break; // HKEY_PERFORMANCE_DATA - } - - // If a potential base key was found, see if keyName actually starts with the potential base key's name. - if (baseKey != null && keyName.StartsWith(baseKey.Name, StringComparison.OrdinalIgnoreCase)) - { - subKeyName = (i == -1 || i == keyName.Length) ? - string.Empty : - keyName.Substring(i + 1, keyName.Length - i - 1); - - return baseKey; - } - - throw new ArgumentException(SR.Format(SR.Arg_RegInvalidKeyName, nameof(keyName)), nameof(keyName)); - } - - public static object GetValue(string keyName, string valueName, object defaultValue) - { - string subKeyName; - RegistryKey basekey = GetBaseKeyFromKeyName(keyName, out subKeyName); - - using (RegistryKey key = basekey.OpenSubKey(subKeyName)) - { - return key?.GetValue(valueName, defaultValue); - } - } - - public static void SetValue(string keyName, string valueName, object value) - { - SetValue(keyName, valueName, value, RegistryValueKind.Unknown); - } - - public static void SetValue(string keyName, string valueName, object value, RegistryValueKind valueKind) - { - string subKeyName; - RegistryKey basekey = GetBaseKeyFromKeyName(keyName, out subKeyName); - - using (RegistryKey key = basekey.CreateSubKey(subKeyName)) - { - Debug.Assert(key != null, "An exception should be thrown if failed!"); - key.SetValue(valueName, value, valueKind); - } - } -#endif - } -} diff --git a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryHive.cs b/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryHive.cs deleted file mode 100644 index 0f1e9541c8..0000000000 --- a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryHive.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Win32 -{ - /** - * Registry hive values. Useful only for GetRemoteBaseKey - */ -#if REGISTRY_ASSEMBLY - public -#else - internal -#endif - enum RegistryHive - { - ClassesRoot = unchecked((int)0x80000000), - CurrentUser = unchecked((int)0x80000001), - LocalMachine = unchecked((int)0x80000002), - Users = unchecked((int)0x80000003), - PerformanceData = unchecked((int)0x80000004), - CurrentConfig = unchecked((int)0x80000005), - } -}
\ No newline at end of file diff --git a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryOptions.cs b/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryOptions.cs deleted file mode 100644 index 201a6df0ec..0000000000 --- a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryOptions.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Win32 -{ - [Flags] -#if REGISTRY_ASSEMBLY - public -#else - internal -#endif - enum RegistryOptions - { - None = Interop.Advapi32.RegistryOptions.REG_OPTION_NON_VOLATILE, // 0x0000 - Volatile = Interop.Advapi32.RegistryOptions.REG_OPTION_VOLATILE, // 0x0001 - }; -} diff --git a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryValueKind.cs b/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryValueKind.cs deleted file mode 100644 index bc6efcc06f..0000000000 --- a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryValueKind.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.Win32 -{ -#if REGISTRY_ASSEMBLY - public -#else - internal -#endif - enum RegistryValueKind - { - String = Interop.Advapi32.RegistryValues.REG_SZ, - ExpandString = Interop.Advapi32.RegistryValues.REG_EXPAND_SZ, - Binary = Interop.Advapi32.RegistryValues.REG_BINARY, - DWord = Interop.Advapi32.RegistryValues.REG_DWORD, - MultiString = Interop.Advapi32.RegistryValues.REG_MULTI_SZ, - QWord = Interop.Advapi32.RegistryValues.REG_QWORD, - Unknown = 0, // REG_NONE is defined as zero but BCL - None = unchecked((int)0xFFFFFFFF), // mistakenly overrode this value. - } // Now instead of using Interop.Kernel32.RegistryValues.REG_NONE we use "-1". -} diff --git a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryValueOptions.cs b/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryValueOptions.cs deleted file mode 100644 index 7d9b6c403b..0000000000 --- a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryValueOptions.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Win32 -{ - [Flags] -#if REGISTRY_ASSEMBLY - public -#else - internal -#endif - enum RegistryValueOptions - { - None = 0, - DoNotExpandEnvironmentNames = 1 - } -} diff --git a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryView.cs b/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryView.cs deleted file mode 100644 index 0d6b3038e8..0000000000 --- a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryView.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace Microsoft.Win32 -{ -#if REGISTRY_ASSEMBLY - public -#else - internal -#endif - enum RegistryView - { - Default = 0, // 0x0000 operate on the default registry view - Registry64 = Interop.Advapi32.RegistryView.KEY_WOW64_64KEY, // 0x0100 operate on the 64-bit registry view - Registry32 = Interop.Advapi32.RegistryView.KEY_WOW64_32KEY, // 0x0200 operate on the 32-bit registry view - }; -} diff --git a/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeRegistryHandle.Windows.cs b/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeRegistryHandle.Windows.cs index 9b668047a9..249f5e9f7c 100644 --- a/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeRegistryHandle.Windows.cs +++ b/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeRegistryHandle.Windows.cs @@ -2,9 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.Win32.SafeHandles; using System.Runtime.InteropServices; +#if REGISTRY_ASSEMBLY namespace Microsoft.Win32.SafeHandles +#else +namespace Internal.Win32.SafeHandles +#endif { #if REGISTRY_ASSEMBLY public diff --git a/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs b/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs index ae35b03d54..37e350031b 100644 --- a/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs +++ b/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeRegistryHandle.cs @@ -2,9 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.Win32.SafeHandles; using System; +#if REGISTRY_ASSEMBLY namespace Microsoft.Win32.SafeHandles +#else +namespace Internal.Win32.SafeHandles +#endif { #if REGISTRY_ASSEMBLY public |