Index: base/applications/regedit/framewnd.c =================================================================== --- base/applications/regedit/framewnd.c (revision 48388) +++ base/applications/regedit/framewnd.c (working copy) @@ -95,7 +95,7 @@ dwIndex = 0; do { - cbValueName = sizeof(szValueName) / sizeof(szValueName[0]); + cbValueName = COUNT_OF(szValueName); cbValueData = sizeof(abValueData); lResult = RegEnumValue(hKey, dwIndex, szValueName, &cbValueName, NULL, &dwType, abValueData, &cbValueData); if ((lResult == ERROR_SUCCESS) && (dwType == REG_SZ)) @@ -543,10 +543,10 @@ if (!EmptyClipboard()) goto done; - if (!RegKeyGetName(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), hRootKey, keyName)) + if (!RegKeyGetName(szBuffer, COUNT_OF(szBuffer), hRootKey, keyName)) goto done; - hGlobal = GlobalAlloc(GMEM_MOVEABLE, (_tcslen(szBuffer) + 1) * sizeof(TCHAR)); + hGlobal = GlobalAlloc(GMEM_MOVEABLE, (lstrlen(szBuffer) + 1) * sizeof(TCHAR)); if (!hGlobal) goto done; @@ -578,21 +578,18 @@ HKEY hKey; LVFINDINFO lvfi; - if (RegOpenKey(hRootKey, pszKeyPath, &hKey) != ERROR_SUCCESS) + if (RegOpenKeyEx(hRootKey, pszKeyPath, 0, KEY_QUERY_VALUE | KEY_SET_VALUE, + &hKey) != ERROR_SUCCESS) return FALSE; - LoadString(hInst, IDS_NEW_VALUE, szNewValueFormat, sizeof(szNewValueFormat) - / sizeof(szNewValueFormat[0])); + LoadString(hInst, IDS_NEW_VALUE, szNewValueFormat, COUNT_OF(szNewValueFormat)); do { - _sntprintf(szNewValue, sizeof(szNewValue) / sizeof(szNewValue[0]), - szNewValueFormat, iIndex++); - + wsprintf(szNewValue, szNewValueFormat, iIndex++); cbData = sizeof(data); lResult = RegQueryValueEx(hKey, szNewValue, NULL, &dwExistingType, data, &cbData); - } - while(lResult == ERROR_SUCCESS); + } while(lResult == ERROR_SUCCESS); switch(dwType) { case REG_DWORD: @@ -614,8 +611,11 @@ } memset(data, 0, cbData); lResult = RegSetValueEx(hKey, szNewValue, 0, dwType, data, cbData); + RegCloseKey(hKey); if (lResult != ERROR_SUCCESS) + { return FALSE; + } RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath); @@ -887,7 +887,7 @@ } } } - if (GetFocus() == g_pChildWnd->hTreeWnd) + else if (GetFocus() == g_pChildWnd->hTreeWnd) { /* Get focused entry of treeview (if any) */ HTREEITEM hItem = TreeView_GetSelection(g_pChildWnd->hTreeWnd); @@ -930,8 +930,8 @@ } } } - } else - if (GetFocus() == g_pChildWnd->hTreeWnd) + } + else if (GetFocus() == g_pChildWnd->hTreeWnd) { if (keyPath == 0 || *keyPath == 0) { @@ -943,7 +943,8 @@ RefreshTreeView(g_pChildWnd->hTreeWnd); } } - break; + break; + } case ID_EDIT_NEW_STRINGVALUE: CreateNewValue(hKeyRoot, keyPath, REG_SZ); break; @@ -953,14 +954,12 @@ case ID_EDIT_NEW_DWORDVALUE: CreateNewValue(hKeyRoot, keyPath, REG_DWORD); break; - case ID_EDIT_NEW_MULTISTRINGVALUE: + case ID_EDIT_NEW_MULTISTRINGVALUE: CreateNewValue(hKeyRoot, keyPath, REG_MULTI_SZ); break; - case ID_EDIT_NEW_EXPANDABLESTRINGVALUE: + case ID_EDIT_NEW_EXPANDABLESTRINGVALUE: CreateNewValue(hKeyRoot, keyPath, REG_EXPAND_SZ); break; - - } case ID_EDIT_FIND: FindDialog(hWnd); break;