Author: cwittich Date: Sun Jul 29 14:33:17 2007 New Revision: 27994
URL: http://svn.reactos.org/svn/reactos?rev=27994&view=rev Log: fix bug "Regedit will let you create two identical keys." See issue #2496 for more details.
Modified: trunk/reactos/base/applications/regedit/childwnd.c
Modified: trunk/reactos/base/applications/regedit/childwnd.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/regedit/c... ============================================================================== --- trunk/reactos/base/applications/regedit/childwnd.c (original) +++ trunk/reactos/base/applications/regedit/childwnd.c Sun Jul 29 14:33:17 2007 @@ -510,6 +510,7 @@ { LPCTSTR keyPath; HKEY hRootKey; + HKEY hKey = NULL; LPNMTVDISPINFO ptvdi; LONG lResult;
@@ -517,9 +518,18 @@ 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;