fix bug "Regedit will let you create two identical keys."

See issue #2496 for more details.

svn path=/trunk/; revision=27994
This commit is contained in:
Christoph von Wittich 2007-07-29 10:33:17 +00:00
parent d675ad4eb0
commit b9f016c611

View file

@ -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;