forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dotnet#1119 from pallavit/ConsolidateInteropCalls
Consolidate interop calls for Microsoft.Win32.Registry
- Loading branch information
Showing
25 changed files
with
534 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
internal partial class Errors | ||
{ | ||
internal const int ERROR_SUCCESS = 0x0; | ||
internal const int ERROR_FILE_NOT_FOUND = 0x2; | ||
internal const int ERROR_ACCESS_DENIED = 0x5; | ||
internal const int ERROR_INVALID_HANDLE = 0x6; | ||
internal const int ERROR_FILENAME_EXCED_RANGE = 0xCE; // filename too long. | ||
internal const int ERROR_MORE_DATA = 0xEA; | ||
internal const int ERROR_DLL_INIT_FAILED = 0x45A; | ||
internal const int ERROR_BAD_IMPERSONATION_LEVEL = 0x542; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/Common/src/Interop/Windows/mincore/Interop.RegCloseKey.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32.SafeHandles; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Registry_L1)] | ||
internal extern static int RegCloseKey(IntPtr hKey); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Common/src/Interop/Windows/mincore/Interop.RegConnectRegistry.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32.SafeHandles; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Registry_L2, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegConnectRegistryW")] | ||
internal static extern int RegConnectRegistry(String machineName, SafeRegistryHandle key, out SafeRegistryHandle result); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Common/src/Interop/Windows/mincore/Interop.RegCreateKeyEx.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32.SafeHandles; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
// Note: RegCreateKeyEx won't set the last error on failure - it returns | ||
// an error code if it fails. | ||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegCreateKeyExW")] | ||
internal static extern int RegCreateKeyEx( | ||
SafeRegistryHandle hKey, | ||
String lpSubKey, | ||
int Reserved, | ||
String lpClass, | ||
int dwOptions, | ||
int samDesired, | ||
ref SECURITY_ATTRIBUTES secAttrs, | ||
out SafeRegistryHandle hkResult, | ||
out int lpdwDisposition); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Common/src/Interop/Windows/mincore/Interop.RegDeleteKeyEx.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32.SafeHandles; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegDeleteKeyExW")] | ||
internal static extern int RegDeleteKeyEx(SafeRegistryHandle hKey, String lpSubKey, int samDesired, int Reserved); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Common/src/Interop/Windows/mincore/Interop.RegDeleteValue.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32.SafeHandles; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegDeleteValueW")] | ||
internal static extern int RegDeleteValue(SafeRegistryHandle hKey, String lpValueName); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Common/src/Interop/Windows/mincore/Interop.RegEnumKeyEx.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32.SafeHandles; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegEnumKeyExW")] | ||
internal unsafe static extern int RegEnumKeyEx( | ||
SafeRegistryHandle hKey, | ||
int dwIndex, | ||
char* lpName, | ||
ref int lpcbName, | ||
int[] lpReserved, | ||
[Out]StringBuilder lpClass, | ||
int[] lpcbClass, | ||
long[] lpftLastWriteTime); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Common/src/Interop/Windows/mincore/Interop.RegEnumValue.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32.SafeHandles; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegEnumValueW")] | ||
internal unsafe static extern int RegEnumValue( | ||
SafeRegistryHandle hKey, | ||
int dwIndex, | ||
char* lpValueName, | ||
ref int lpcbValueName, | ||
IntPtr lpReserved_MustBeZero, | ||
int[] lpType, | ||
byte[] lpData, | ||
int[] lpcbData); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Common/src/Interop/Windows/mincore/Interop.RegFlushKey.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32.SafeHandles; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Registry_L1)] | ||
internal static extern int RegFlushKey(SafeRegistryHandle hKey); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Common/src/Interop/Windows/mincore/Interop.RegOpenKeyEx.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32.SafeHandles; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegOpenKeyExW")] | ||
internal static extern int RegOpenKeyEx( | ||
SafeRegistryHandle hKey, | ||
string lpSubKey, | ||
int ulOptions, | ||
int samDesired, | ||
out SafeRegistryHandle hkResult); | ||
|
||
|
||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegOpenKeyExW")] | ||
internal static extern int RegOpenKeyEx( | ||
IntPtr hKey, | ||
string lpSubKey, | ||
int ulOptions, | ||
int samDesired, | ||
out SafeRegistryHandle hkResult); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Common/src/Interop/Windows/mincore/Interop.RegQueryInfoKey.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32.SafeHandles; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryInfoKeyW")] | ||
internal static extern int RegQueryInfoKey( | ||
SafeRegistryHandle hKey, | ||
[Out]StringBuilder lpClass, | ||
int[] lpcbClass, | ||
IntPtr lpReserved_MustBeZero, | ||
ref int lpcSubKeys, | ||
int[] lpcbMaxSubKeyLen, | ||
int[] lpcbMaxClassLen, | ||
ref int lpcValues, | ||
int[] lpcbMaxValueNameLen, | ||
int[] lpcbMaxValueLen, | ||
int[] lpcbSecurityDescriptor, | ||
int[] lpftLastWriteTime); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/Common/src/Interop/Windows/mincore/Interop.RegQueryValueEx.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32.SafeHandles; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW")] | ||
internal static extern int RegQueryValueEx( | ||
SafeRegistryHandle hKey, | ||
string lpValueName, | ||
int[] lpReserved, | ||
ref int lpType, | ||
[Out] byte[] lpData, | ||
ref int lpcbData); | ||
|
||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW")] | ||
internal static extern int RegQueryValueEx( | ||
SafeRegistryHandle hKey, | ||
string lpValueName, | ||
int[] lpReserved, | ||
ref int lpType, | ||
ref int lpData, | ||
ref int lpcbData); | ||
|
||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW")] | ||
internal static extern int RegQueryValueEx( | ||
SafeRegistryHandle hKey, | ||
String lpValueName, | ||
int[] lpReserved, | ||
ref int lpType, | ||
ref long lpData, | ||
ref int lpcbData); | ||
|
||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW")] | ||
internal static extern int RegQueryValueEx( | ||
SafeRegistryHandle hKey, | ||
String lpValueName, | ||
int[] lpReserved, | ||
ref int lpType, | ||
[Out] char[] lpData, | ||
ref int lpcbData); | ||
|
||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW")] | ||
internal static extern int RegQueryValueEx( | ||
SafeRegistryHandle hKey, | ||
String lpValueName, | ||
int[] lpReserved, | ||
ref int lpType, | ||
[Out]StringBuilder lpData, | ||
ref int lpcbData); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/Common/src/Interop/Windows/mincore/Interop.RegSetValueEx.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32; | ||
using Microsoft.Win32.SafeHandles; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class mincore | ||
{ | ||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW")] | ||
internal static extern int RegSetValueEx( | ||
SafeRegistryHandle hKey, | ||
String lpValueName, | ||
int Reserved, | ||
RegistryValueKind dwType, | ||
byte[] lpData, | ||
int cbData); | ||
|
||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW")] | ||
internal static extern int RegSetValueEx( | ||
SafeRegistryHandle hKey, | ||
String lpValueName, | ||
int Reserved, | ||
RegistryValueKind dwType, | ||
char[] lpData, | ||
int cbData); | ||
|
||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW")] | ||
internal static extern int RegSetValueEx( | ||
SafeRegistryHandle hKey, | ||
String lpValueName, | ||
int Reserved, | ||
RegistryValueKind dwType, | ||
ref int lpData, | ||
int cbData); | ||
|
||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW")] | ||
internal static extern int RegSetValueEx( | ||
SafeRegistryHandle hKey, | ||
String lpValueName, | ||
int Reserved, | ||
RegistryValueKind dwType, | ||
ref long lpData, | ||
int cbData); | ||
|
||
[DllImport(Libraries.Registry_L1, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW")] | ||
internal static extern int RegSetValueEx( | ||
SafeRegistryHandle hKey, | ||
String lpValueName, | ||
int Reserved, | ||
RegistryValueKind dwType, | ||
String lpData, | ||
int cbData); | ||
} | ||
} |
Oops, something went wrong.