mirror of
https://github.com/reactos/reactos.git
synced 2024-08-06 11:24:58 +00:00
[ADVAPI32]
- Centralize RegDeleteKey[Ex]{A,W} implementation into RegDeleteKeyExW - Update the HKCR wrapper accordingly. CORE-8582 svn path=/trunk/; revision=64427
This commit is contained in:
parent
c9143ec6b0
commit
89722b00b4
|
@ -272,7 +272,9 @@ LONG
|
||||||
WINAPI
|
WINAPI
|
||||||
DeleteHKCRKey(
|
DeleteHKCRKey(
|
||||||
_In_ HKEY hKey,
|
_In_ HKEY hKey,
|
||||||
_In_ LPCWSTR lpSubKey)
|
_In_ LPCWSTR lpSubKey,
|
||||||
|
_In_ REGSAM RegSam,
|
||||||
|
_In_ DWORD Reserved)
|
||||||
{
|
{
|
||||||
HKEY QueriedKey;
|
HKEY QueriedKey;
|
||||||
LONG ErrorCode;
|
LONG ErrorCode;
|
||||||
|
@ -287,7 +289,7 @@ DeleteHKCRKey(
|
||||||
if (ErrorCode == ERROR_FILE_NOT_FOUND)
|
if (ErrorCode == ERROR_FILE_NOT_FOUND)
|
||||||
{
|
{
|
||||||
/* The key doesn't exist on HKCU side, no chance for a subkey */
|
/* The key doesn't exist on HKCU side, no chance for a subkey */
|
||||||
return RegDeleteKeyW(hKey, lpSubKey);
|
return RegDeleteKeyExW(hKey, lpSubKey, RegSam, Reserved);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ErrorCode != ERROR_SUCCESS)
|
if (ErrorCode != ERROR_SUCCESS)
|
||||||
|
@ -296,7 +298,7 @@ DeleteHKCRKey(
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode = RegDeleteKeyW(QueriedKey, lpSubKey);
|
ErrorCode = RegDeleteKeyExW(QueriedKey, lpSubKey, RegSam, Reserved);
|
||||||
|
|
||||||
/* Close it if we must */
|
/* Close it if we must */
|
||||||
if (QueriedKey != hKey)
|
if (QueriedKey != hKey)
|
||||||
|
@ -317,7 +319,7 @@ DeleteHKCRKey(
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode = RegDeleteKeyW(QueriedKey, lpSubKey);
|
ErrorCode = RegDeleteKeyExW(QueriedKey, lpSubKey, RegSam, Reserved);
|
||||||
|
|
||||||
/* Close it if we must */
|
/* Close it if we must */
|
||||||
if (QueriedKey != hKey)
|
if (QueriedKey != hKey)
|
||||||
|
|
|
@ -1181,20 +1181,13 @@ RegCreateKeyW(HKEY hKey,
|
||||||
*
|
*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
LONG WINAPI
|
LONG
|
||||||
RegDeleteKeyA(HKEY hKey,
|
WINAPI
|
||||||
LPCSTR lpSubKey)
|
RegDeleteKeyA(
|
||||||
|
_In_ HKEY hKey,
|
||||||
|
_In_ LPCSTR lpSubKey)
|
||||||
{
|
{
|
||||||
LONG ErrorCode;
|
return RegDeleteKeyExA(hKey, lpSubKey, 0, 0);
|
||||||
UNICODE_STRING SubKeyName;
|
|
||||||
|
|
||||||
RtlCreateUnicodeStringFromAsciiz(&SubKeyName, (LPSTR)lpSubKey);
|
|
||||||
|
|
||||||
ErrorCode = RegDeleteKeyW(hKey, SubKeyName.Buffer);
|
|
||||||
|
|
||||||
RtlFreeUnicodeString(&SubKeyName);
|
|
||||||
|
|
||||||
return ErrorCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1203,9 +1196,54 @@ RegDeleteKeyA(HKEY hKey,
|
||||||
*
|
*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
LONG WINAPI
|
LONG
|
||||||
RegDeleteKeyW(HKEY hKey,
|
WINAPI
|
||||||
LPCWSTR lpSubKey)
|
RegDeleteKeyW(
|
||||||
|
_In_ HKEY hKey,
|
||||||
|
_In_ LPCWSTR lpSubKey)
|
||||||
|
{
|
||||||
|
return RegDeleteKeyExW(hKey, lpSubKey, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* RegDeleteKeyExA
|
||||||
|
*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
LONG
|
||||||
|
WINAPI
|
||||||
|
RegDeleteKeyExA(
|
||||||
|
_In_ HKEY hKey,
|
||||||
|
_In_ LPCSTR lpSubKey,
|
||||||
|
_In_ REGSAM samDesired,
|
||||||
|
_In_ DWORD Reserved)
|
||||||
|
{
|
||||||
|
LONG ErrorCode;
|
||||||
|
UNICODE_STRING SubKeyName;
|
||||||
|
|
||||||
|
RtlCreateUnicodeStringFromAsciiz(&SubKeyName, (LPSTR)lpSubKey);
|
||||||
|
|
||||||
|
ErrorCode = RegDeleteKeyExW(hKey, SubKeyName.Buffer, samDesired, Reserved);
|
||||||
|
|
||||||
|
RtlFreeUnicodeString(&SubKeyName);
|
||||||
|
|
||||||
|
return ErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* RegDeleteKeyExW
|
||||||
|
*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
LONG
|
||||||
|
WINAPI
|
||||||
|
RegDeleteKeyExW(
|
||||||
|
_In_ HKEY hKey,
|
||||||
|
_In_ LPCWSTR lpSubKey,
|
||||||
|
_In_ REGSAM samDesired,
|
||||||
|
_In_ DWORD Reserved)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
UNICODE_STRING SubKeyName;
|
UNICODE_STRING SubKeyName;
|
||||||
|
@ -1228,139 +1266,7 @@ RegDeleteKeyW(HKEY hKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsHKCRKey(ParentKey))
|
if (IsHKCRKey(ParentKey))
|
||||||
return DeleteHKCRKey(ParentKey, lpSubKey);
|
return DeleteHKCRKey(ParentKey, lpSubKey, samDesired, Reserved);
|
||||||
|
|
||||||
RtlInitUnicodeString(&SubKeyName,
|
|
||||||
(LPWSTR)lpSubKey);
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&SubKeyName,
|
|
||||||
OBJ_CASE_INSENSITIVE,
|
|
||||||
ParentKey,
|
|
||||||
NULL);
|
|
||||||
Status = NtOpenKey(&TargetKey,
|
|
||||||
DELETE,
|
|
||||||
&ObjectAttributes);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
goto Cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = NtDeleteKey(TargetKey);
|
|
||||||
NtClose(TargetKey);
|
|
||||||
|
|
||||||
Cleanup:
|
|
||||||
ClosePredefKey(ParentKey);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return RtlNtStatusToDosError(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* RegDeleteKeyExA
|
|
||||||
*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
LONG
|
|
||||||
WINAPI
|
|
||||||
RegDeleteKeyExA(HKEY hKey,
|
|
||||||
LPCSTR lpSubKey,
|
|
||||||
REGSAM samDesired,
|
|
||||||
DWORD Reserved)
|
|
||||||
{
|
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
UNICODE_STRING SubKeyName;
|
|
||||||
HANDLE ParentKey;
|
|
||||||
HANDLE TargetKey;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
/* Make sure we got a subkey */
|
|
||||||
if (!lpSubKey)
|
|
||||||
{
|
|
||||||
/* Fail */
|
|
||||||
return ERROR_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = MapDefaultKey(&ParentKey,
|
|
||||||
hKey);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return RtlNtStatusToDosError(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (samDesired & KEY_WOW64_32KEY)
|
|
||||||
ERR("Wow64 not yet supported!\n");
|
|
||||||
|
|
||||||
if (samDesired & KEY_WOW64_64KEY)
|
|
||||||
ERR("Wow64 not yet supported!\n");
|
|
||||||
|
|
||||||
RtlCreateUnicodeStringFromAsciiz(&SubKeyName,
|
|
||||||
(LPSTR)lpSubKey);
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&SubKeyName,
|
|
||||||
OBJ_CASE_INSENSITIVE,
|
|
||||||
ParentKey,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
Status = NtOpenKey(&TargetKey,
|
|
||||||
DELETE,
|
|
||||||
&ObjectAttributes);
|
|
||||||
RtlFreeUnicodeString(&SubKeyName);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
goto Cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = NtDeleteKey(TargetKey);
|
|
||||||
NtClose (TargetKey);
|
|
||||||
|
|
||||||
Cleanup:
|
|
||||||
ClosePredefKey(ParentKey);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return RtlNtStatusToDosError(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* RegDeleteKeyExW
|
|
||||||
*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
LONG
|
|
||||||
WINAPI
|
|
||||||
RegDeleteKeyExW(HKEY hKey,
|
|
||||||
LPCWSTR lpSubKey,
|
|
||||||
REGSAM samDesired,
|
|
||||||
DWORD Reserved)
|
|
||||||
{
|
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
UNICODE_STRING SubKeyName;
|
|
||||||
HANDLE ParentKey;
|
|
||||||
HANDLE TargetKey;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
/* Make sure we got a subkey */
|
|
||||||
if (!lpSubKey)
|
|
||||||
{
|
|
||||||
/* Fail */
|
|
||||||
return ERROR_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = MapDefaultKey(&ParentKey,
|
|
||||||
hKey);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return RtlNtStatusToDosError(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (samDesired & KEY_WOW64_32KEY)
|
if (samDesired & KEY_WOW64_32KEY)
|
||||||
ERR("Wow64 not yet supported!\n");
|
ERR("Wow64 not yet supported!\n");
|
||||||
|
|
|
@ -35,5 +35,7 @@ LONG
|
||||||
WINAPI
|
WINAPI
|
||||||
DeleteHKCRKey(
|
DeleteHKCRKey(
|
||||||
_In_ HKEY hKey,
|
_In_ HKEY hKey,
|
||||||
_In_ LPCWSTR lpSubKey);
|
_In_ LPCWSTR lpSubKey,
|
||||||
|
_In_ REGSAM RegSam,
|
||||||
|
_In_ DWORD Reserved);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue