<Compile Include="$(BclSourcesRoot)\System\Collections\ObjectModel\ReadOnlyDictionary.cs" />
</ItemGroup>
<ItemGroup>
- <Compile Condition="'$(FeatureWin32Registry)' == 'true'" Include="$(BclSourcesRoot)\Microsoft\Win32\SafeHandles\SafeRegistryHandle.cs" />
- </ItemGroup>
- <ItemGroup>
<Compile Include="$(BclSourcesRoot)\System\Numerics\Hashing\HashHelpers.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
--- /dev/null
+// 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.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal partial class Advapi32
+ {
+ [DllImport(Libraries.Advapi32)]
+ internal static extern int RegCloseKey(IntPtr hKey);
+ }
+}
{
internal static partial class Libraries
{
+ internal const string Advapi32 = "advapi32.dll";
internal const string BCrypt = "BCrypt.dll";
internal const string Crypt32 = "crypt32.dll";
internal const string Kernel32 = "kernel32.dll";
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-//
-//
-// Implements Microsoft.Win32.SafeHandles.SafeRegistryHandle
-//
-// ======================================================================================
-
using System;
using System.Security;
using System.Runtime.InteropServices;
namespace Microsoft.Win32.SafeHandles
{
- internal sealed class SafeRegistryHandle : SafeHandleZeroOrMinusOneIsInvalid
+#if REGISTRY_ASSEMBLY
+ public
+#else
+ internal
+#endif
+ sealed class SafeRegistryHandle : SafeHandleZeroOrMinusOneIsInvalid
{
internal SafeRegistryHandle() : base(true) { }
SetHandle(preexistingHandle);
}
- override protected bool ReleaseHandle()
+ protected override bool ReleaseHandle()
{
- return (RegCloseKey(handle) == Interop.Errors.ERROR_SUCCESS);
+ return (Interop.Advapi32.RegCloseKey(handle) == Interop.Errors.ERROR_SUCCESS);
}
-
- [DllImport(Win32Native.ADVAPI32)]
- internal static extern int RegCloseKey(IntPtr hKey);
}
}
-
<Compile Include="$(MSBuildThisFileDirectory)System\IO\FileStream.Win32.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\TimeZoneInfo.Win32.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeLibraryHandle.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)\Microsoft\Win32\SafeHandles\SafeRegistryHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.LoadLibraryEx.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.FreeLibrary.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.CreateFile.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.MUI.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Advapi32\Interop.RegCloseKey.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.TimeZone.Registry.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\User32\Interop.Constants.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\User32\Interop.SendMessageTimeout.cs" />
// the dispose below and usage elsewhere (other threads). This is By Design.
// This is less of an issue when OS > NT5 (i.e Vista & higher), we can close the perfkey
// (to release & refresh PERFLIB resources) and the OS will rebuild PERFLIB as necessary.
- SafeRegistryHandle.RegCloseKey(RegistryKey.HKEY_PERFORMANCE_DATA);
+ Interop.Advapi32.RegCloseKey(RegistryKey.HKEY_PERFORMANCE_DATA);
}
}
}