mirror of
https://github.com/reactos/reactos.git
synced 2024-08-06 11:24:58 +00:00
[ADVAPI32]
- Implement DeleteKey for HKCR subkeys CORE-8582 svn path=/trunk/; revision=64421
This commit is contained in:
parent
3b1ab5bd6a
commit
ca7384efaa
|
@ -238,7 +238,6 @@ OpenHKCRKey(
|
||||||
/* Close it if we must */
|
/* Close it if we must */
|
||||||
if (QueriedKey != hKey)
|
if (QueriedKey != hKey)
|
||||||
{
|
{
|
||||||
/* The original key is on the machine view */
|
|
||||||
RegCloseKey(QueriedKey);
|
RegCloseKey(QueriedKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +260,66 @@ OpenHKCRKey(
|
||||||
/* Close it if we must */
|
/* Close it if we must */
|
||||||
if (QueriedKey != hKey)
|
if (QueriedKey != hKey)
|
||||||
{
|
{
|
||||||
/* The original key is on the machine view */
|
RegCloseKey(QueriedKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
LONG
|
||||||
|
WINAPI
|
||||||
|
DeleteHKCRKey(
|
||||||
|
_In_ HKEY hKey,
|
||||||
|
_In_ LPCWSTR lpSubKey)
|
||||||
|
{
|
||||||
|
HKEY QueriedKey;
|
||||||
|
LONG ErrorCode;
|
||||||
|
|
||||||
|
ASSERT(IsHKCRKey(hKey));
|
||||||
|
|
||||||
|
/* Remove the HKCR flag while we're working */
|
||||||
|
hKey = (HKEY)(((ULONG_PTR)hKey) & ~0x2);
|
||||||
|
|
||||||
|
ErrorCode = GetPreferredHKCRKey(hKey, &QueriedKey);
|
||||||
|
|
||||||
|
if (ErrorCode == ERROR_FILE_NOT_FOUND)
|
||||||
|
{
|
||||||
|
/* The key doesn't exist on HKCU side, no chance for a subkey */
|
||||||
|
return RegDeleteKeyW(hKey, lpSubKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ErrorCode != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Somehow we failed for another reason (maybe deleted key or whatever) */
|
||||||
|
return ErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorCode = RegDeleteKeyW(QueriedKey, lpSubKey);
|
||||||
|
|
||||||
|
/* Close it if we must */
|
||||||
|
if (QueriedKey != hKey)
|
||||||
|
{
|
||||||
|
/* The original key is on the machine view */
|
||||||
|
RegCloseKey(QueriedKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Anything else than ERROR_FILE_NOT_FOUND means that we found it, even if it is with failures. */
|
||||||
|
if (ErrorCode != ERROR_FILE_NOT_FOUND)
|
||||||
|
return ErrorCode;
|
||||||
|
|
||||||
|
/* If we're here, we must open from HKLM key. */
|
||||||
|
ErrorCode = GetFallbackHKCRKey(hKey, &QueriedKey);
|
||||||
|
if (ErrorCode != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Maybe the key doesn't exist in the HKLM view */
|
||||||
|
return ErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorCode = RegDeleteKeyW(QueriedKey, lpSubKey);
|
||||||
|
|
||||||
|
/* Close it if we must */
|
||||||
|
if (QueriedKey != hKey)
|
||||||
|
{
|
||||||
RegCloseKey(QueriedKey);
|
RegCloseKey(QueriedKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1227,6 +1227,9 @@ RegDeleteKeyW(HKEY hKey,
|
||||||
return RtlNtStatusToDosError(Status);
|
return RtlNtStatusToDosError(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsHKCRKey(ParentKey))
|
||||||
|
return DeleteHKCRKey(ParentKey, lpSubKey);
|
||||||
|
|
||||||
RtlInitUnicodeString(&SubKeyName,
|
RtlInitUnicodeString(&SubKeyName,
|
||||||
(LPWSTR)lpSubKey);
|
(LPWSTR)lpSubKey);
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
|
|
@ -30,3 +30,10 @@ OpenHKCRKey(
|
||||||
_In_ DWORD ulOptions,
|
_In_ DWORD ulOptions,
|
||||||
_In_ REGSAM samDesired,
|
_In_ REGSAM samDesired,
|
||||||
_In_ PHKEY phkResult);
|
_In_ PHKEY phkResult);
|
||||||
|
|
||||||
|
LONG
|
||||||
|
WINAPI
|
||||||
|
DeleteHKCRKey(
|
||||||
|
_In_ HKEY hKey,
|
||||||
|
_In_ LPCWSTR lpSubKey);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue