Commit 1a5a8494 authored by James Forshaw's avatar James Forshaw Committed by Commit Bot

Call RegDeleteKeyEx directly instead of via a wrapper.

This CL removed the old wrapper for RegDeleteKeyEx which was used for
compatibility with Windows XP. As the code base is only supported on
Windows 7 and above this function can be statically linked.

Bug: 986625
Change-Id: I46814d7758948c371de42f66a6e9e96e4a6bfb87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1714289Reviewed-by: default avatarBruce Dawson <brucedawson@chromium.org>
Commit-Queue: James Forshaw <forshaw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680128}
parent 2f8b1f7b
...@@ -281,7 +281,7 @@ LONG RegKey::DeleteEmptyKey(const char16* name) { ...@@ -281,7 +281,7 @@ LONG RegKey::DeleteEmptyKey(const char16* name) {
return result; return result;
if (count == 0) if (count == 0)
return RegDeleteKeyExWrapper(key_, name, wow64access_, 0); return RegDeleteKeyEx(key_, name, wow64access_, 0);
return ERROR_DIR_NOT_EMPTY; return ERROR_DIR_NOT_EMPTY;
} }
...@@ -430,29 +430,10 @@ bool RegKey::StartWatching(ChangeCallback callback) { ...@@ -430,29 +430,10 @@ bool RegKey::StartWatching(ChangeCallback callback) {
return true; return true;
} }
// static
LONG RegKey::RegDeleteKeyExWrapper(HKEY hKey,
const char16* lpSubKey,
REGSAM samDesired,
DWORD Reserved) {
typedef LSTATUS(WINAPI* RegDeleteKeyExPtr)(HKEY, LPCWSTR, REGSAM, DWORD);
RegDeleteKeyExPtr reg_delete_key_ex_func =
reinterpret_cast<RegDeleteKeyExPtr>(
GetProcAddress(GetModuleHandleA("advapi32.dll"), "RegDeleteKeyExW"));
if (reg_delete_key_ex_func)
return reg_delete_key_ex_func(hKey, as_wcstr(lpSubKey), samDesired,
Reserved);
// Windows XP does not support RegDeleteKeyEx, so fallback to RegDeleteKey.
return RegDeleteKey(hKey, as_wcstr(lpSubKey));
}
// static // static
LONG RegKey::RegDelRecurse(HKEY root_key, const char16* name, REGSAM access) { LONG RegKey::RegDelRecurse(HKEY root_key, const char16* name, REGSAM access) {
// First, see if the key can be deleted without having to recurse. // First, see if the key can be deleted without having to recurse.
LONG result = RegDeleteKeyExWrapper(root_key, name, access, 0); LONG result = RegDeleteKeyEx(root_key, name, access, 0);
if (result == ERROR_SUCCESS) if (result == ERROR_SUCCESS)
return result; return result;
...@@ -497,7 +478,7 @@ LONG RegKey::RegDelRecurse(HKEY root_key, const char16* name, REGSAM access) { ...@@ -497,7 +478,7 @@ LONG RegKey::RegDelRecurse(HKEY root_key, const char16* name, REGSAM access) {
RegCloseKey(target_key); RegCloseKey(target_key);
// Try again to delete the key. // Try again to delete the key.
result = RegDeleteKeyExWrapper(root_key, name, access, 0); result = RegDeleteKeyEx(root_key, name, access, 0);
return result; return result;
} }
......
...@@ -142,13 +142,6 @@ class BASE_EXPORT RegKey { ...@@ -142,13 +142,6 @@ class BASE_EXPORT RegKey {
private: private:
class Watcher; class Watcher;
// Calls RegDeleteKeyEx on supported platforms, alternatively falls back to
// RegDeleteKey.
static LONG RegDeleteKeyExWrapper(HKEY hKey,
const char16* lpSubKey,
REGSAM samDesired,
DWORD Reserved);
// Recursively deletes a key and all of its subkeys. // Recursively deletes a key and all of its subkeys.
static LONG RegDelRecurse(HKEY root_key, const char16* name, REGSAM access); static LONG RegDelRecurse(HKEY root_key, const char16* name, REGSAM access);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment