From b9f016c6113c74554610686ed74df4e987e79786 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Sun, 29 Jul 2007 10:33:17 +0000 Subject: [PATCH] fix bug "Regedit will let you create two identical keys." See issue #2496 for more details. svn path=/trunk/; revision=27994 --- reactos/base/applications/regedit/childwnd.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/reactos/base/applications/regedit/childwnd.c b/reactos/base/applications/regedit/childwnd.c index c914cb97f6b..594453897ec 100644 --- a/reactos/base/applications/regedit/childwnd.c +++ b/reactos/base/applications/regedit/childwnd.c @@ -510,6 +510,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa { LPCTSTR keyPath; HKEY hRootKey; + HKEY hKey = NULL; LPNMTVDISPINFO ptvdi; LONG lResult; @@ -517,9 +518,18 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa if (ptvdi->item.pszText) { keyPath = GetItemPath(pChildWnd->hTreeWnd, ptvdi->item.hItem, &hRootKey); - lResult = RegRenameKey(hRootKey, keyPath, ptvdi->item.pszText); + if (RegOpenKeyEx(hRootKey, keyPath, 0, KEY_READ, &hKey) == ERROR_SUCCESS) + { + lResult = REG_OPENED_EXISTING_KEY; + RegCloseKey(hKey); + (void)TreeView_EditLabel(pChildWnd->hTreeWnd, ptvdi->item.hItem); + } + else + { + lResult = RegRenameKey(hRootKey, keyPath, ptvdi->item.pszText); + } return lResult == ERROR_SUCCESS; - } + } } default: return 0;