public static object? GetValue(string keyName, string valueName, object defaultValue)
{
- string subKeyName;
- RegistryKey basekey = GetBaseKeyFromKeyName(keyName, out subKeyName);
+ RegistryKey basekey = GetBaseKeyFromKeyName(keyName, out string subKeyName);
using (RegistryKey? key = basekey.OpenSubKey(subKeyName))
{
public static void SetValue(string keyName, string valueName, object value, RegistryValueKind valueKind)
{
- string subKeyName;
- RegistryKey basekey = GetBaseKeyFromKeyName(keyName, out subKeyName);
+ RegistryKey basekey = GetBaseKeyFromKeyName(keyName, out string subKeyName);
using (RegistryKey key = basekey.CreateSubKey(subKeyName))
{
using System.Diagnostics;
using System.IO;
using System.Security;
-using System.Security.AccessControl;
/*
Note on transaction support:
private unsafe RegistryKey CreateSubKeyInternalCore(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions)
{
- Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = default(Interop.Kernel32.SECURITY_ATTRIBUTES);
- int disposition = 0;
+ Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = default;
// By default, the new key will be writable.
int ret = Interop.Advapi32.RegCreateKeyEx(_hkey,
GetRegistryKeyAccess(permissionCheck != RegistryKeyPermissionCheck.ReadSubTree) | (int)_regView,
ref secAttrs,
out SafeRegistryHandle result,
- out disposition);
+ out int _);
if (ret == 0 && !result.IsInvalid)
{
}
// open the base key so that RegistryKey.Handle will return a valid handle
- SafeRegistryHandle result;
ret = Interop.Advapi32.RegOpenKeyEx(baseKey,
null,
0,
GetRegistryKeyAccess(IsWritable()) | (int)_regView,
- out result);
+ out SafeRegistryHandle result);
if (ret == 0 && !result.IsInvalid)
{
// 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
{
public enum RegistryKeyPermissionCheck
Default = 0,
ReadSubTree = 1,
ReadWriteSubTree = 2,
- };
+ }
}
{
None = Interop.Advapi32.RegistryOptions.REG_OPTION_NON_VOLATILE, // 0x0000
Volatile = Interop.Advapi32.RegistryOptions.REG_OPTION_VOLATILE, // 0x0001
- };
+ }
}
// 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
{
public 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
- };
+ }
}
// 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;
-
namespace System.Security.AccessControl
{
// We derived this enum from the definitions of KEY_READ and such from