Commit in reactos/subsys/system/regedit on MAIN
En.rc+61.8 -> 1.9
edit.c+21-141.12 -> 1.13
framewnd.c+44-31.7 -> 1.8
listview.c+22-121.12 -> 1.13
main.h+2-21.4 -> 1.5
resource.h+61.7 -> 1.8
+101-31
6 modified files
added support for deleting values

reactos/subsys/system/regedit
En.rc 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- En.rc	21 Jun 2004 07:48:11 -0000	1.8
+++ En.rc	21 Jun 2004 08:47:38 -0000	1.9
@@ -258,6 +258,11 @@
     IDS_UNSUPPORTED_TYPE    "Can't edit keys of this type (%ld)"
     IDS_TOO_BIG_VALUE       "Value is too big (%ld)"
     IDS_MULTI_SZ_EMPTY_STRING "Data of type REG_MULTI_SZ cannot contain empty strings.\nThe empty strings have been removed from the list."
+    IDS_QUERY_DELETE_ONE    "Are you sure you want to delete this value?"
+    IDS_QUERY_DELETE_MORE   "Are you sure you want to delete these values?"
+    IDS_QUERY_DELETE_CONFIRM "Confirm Value Delete"
+    IDS_ERR_DELVAL_CAPTION  "Error Deleting Values"
+    IDS_ERR_DELETEVALUE     "Unable to delete all specified values!"
 END
 
 STRINGTABLE DISCARDABLE
@@ -269,6 +274,7 @@
     IDS_MY_COMPUTER         "My Computer"
     IDS_IMPORT_REG_FILE     "Import Registry File"
     IDS_EXPORT_REG_FILE     "Export Registry File"
+    IDS_INVALID_DWORD       "(invalid DWORD value)"
 END
 
 STRINGTABLE DISCARDABLE

reactos/subsys/system/regedit
edit.c 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- edit.c	21 Jun 2004 07:48:11 -0000	1.12
+++ edit.c	21 Jun 2004 08:47:38 -0000	1.13
@@ -448,7 +448,7 @@
 }
 
 
-BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
+BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin)
 {
     DWORD type;
     LONG lRet;
@@ -475,7 +475,7 @@
         goto done;
     }
 
-    if ((type == REG_SZ) || (type == REG_EXPAND_SZ))
+    if (EditBin == FALSE && ((type == REG_SZ) || (type == REG_EXPAND_SZ)))
     {
         if (valueDataLen > 0)
         {
@@ -510,7 +510,7 @@
                 result = TRUE;
         }
     }
-    else if (type == REG_MULTI_SZ)
+    else if (EditBin == FALSE && type == REG_MULTI_SZ)
     {
         if (valueDataLen > 0)
         {
@@ -615,7 +615,7 @@
                 result = TRUE;
         }
     }
-    else if (type == REG_DWORD)
+    else if (EditBin == FALSE && type == REG_DWORD)
     {
         lRet = RegQueryValueEx(hKey, valueName, 0, 0, (LPBYTE)&dwordValueData, &valueDataLen);
         if (lRet != ERROR_SUCCESS)
@@ -631,20 +631,27 @@
                 result = TRUE;
         }
     }
-    else if (type == REG_NONE || type == REG_BINARY)
+    else if (EditBin == TRUE || type == REG_NONE || type == REG_BINARY)
     {
-        if(!(binValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen)))
+        if(valueDataLen > 0)
         {
-          error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen);
-          goto done;
+	    if(!(binValueData = HeapAlloc(GetProcessHeap(), 0, valueDataLen)))
+            {
+              error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen);
+              goto done;
+            }
+	    
+	    lRet = RegQueryValueEx(hKey, valueName, 0, 0, (LPBYTE)binValueData, &valueDataLen);
+            if (lRet != ERROR_SUCCESS)
+            {
+                HeapFree(GetProcessHeap(), 0, binValueData);
+	        error(hwnd, IDS_BAD_VALUE, valueName);
+                goto done;
+            }
         }
-	
-	lRet = RegQueryValueEx(hKey, valueName, 0, 0, (LPBYTE)binValueData, &valueDataLen);
-        if (lRet != ERROR_SUCCESS)
+        else
         {
-            HeapFree(GetProcessHeap(), 0, binValueData);
-	    error(hwnd, IDS_BAD_VALUE, valueName);
-            goto done;
+            binValueData = NULL;
         }
 
         if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_BIN_DATA), hwnd, modify_binary_dlgproc) == IDOK)

reactos/subsys/system/regedit
framewnd.c 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- framewnd.c	21 Jun 2004 07:48:11 -0000	1.7
+++ framewnd.c	21 Jun 2004 08:47:38 -0000	1.8
@@ -527,12 +527,14 @@
     }
     case ID_EDIT_RENAME:
     case ID_EDIT_MODIFY:
+    case ID_EDIT_MODIFY_BIN:
+    case ID_EDIT_DELETE:
         regsam |= KEY_WRITE; 
         break;
     }
 
     keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
-    valueName = GetValueName(g_pChildWnd->hListWnd);
+    valueName = GetValueName(g_pChildWnd->hListWnd, -1);
     if (keyPath) {
         lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, regsam, &hKey);
         if (lRet != ERROR_SUCCESS) hKey = 0;
@@ -540,19 +542,58 @@
 
      switch (LOWORD(wParam)) {
     case ID_EDIT_MODIFY:
-        if (valueName && ModifyValue(hWnd, hKey, valueName))
+        if (valueName && ModifyValue(hWnd, hKey, valueName, FALSE))
+            RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
+        break;
+    case ID_EDIT_MODIFY_BIN:
+        if (valueName && ModifyValue(hWnd, hKey, valueName, TRUE))
             RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
         break;
     case ID_EDIT_RENAME:
         if(ListView_GetSelectedCount(g_pChildWnd->hListWnd) == 1)
         {
-          item = ListView_GetNextItem(g_pChildWnd->hListWnd, -1, LVNI_FOCUSED | LVNI_SELECTED);
+          item = ListView_GetNextItem(g_pChildWnd->hListWnd, -1, LVNI_SELECTED);
           if(item > -1)
           {
             ListView_EditLabel(g_pChildWnd->hListWnd, item);
           }
         }
         break;
+    case ID_EDIT_DELETE:
+    {
+        UINT nSelected = ListView_GetSelectedCount(g_pChildWnd->hListWnd);
+        if(nSelected >= 1)
+        {
+          TCHAR msg[128], caption[128];
+          LoadString(hInst, IDS_QUERY_DELETE_CONFIRM, caption, sizeof(caption)/sizeof(TCHAR));
+          LoadString(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, sizeof(msg)/sizeof(TCHAR));
+          if(MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) == IDYES)
+          {
+            int ni, errs;
+            
+	    item = -1;
+	    errs = 0;
+            while((ni = ListView_GetNextItem(g_pChildWnd->hListWnd, item, LVNI_SELECTED)) > -1)
+            {
+              valueName = GetValueName(g_pChildWnd->hListWnd, item);
+              if(RegDeleteValue(hKey, valueName) != ERROR_SUCCESS)
+              {
+                errs++;
+              }
+	      item = ni;
+            }
+            
+            RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
+            if(errs > 0)
+            {
+              LoadString(hInst, IDS_ERR_DELVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR));
+              LoadString(hInst, IDS_ERR_DELETEVALUE, msg, sizeof(msg)/sizeof(TCHAR));
+              MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONSTOP);
+            }
+          }
+        }
+	break;
+    }
     case ID_EDIT_COPYKEYNAME:
         CopyKeyName(hWnd, _T(""));
         break;

reactos/subsys/system/regedit
listview.c 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- listview.c	21 Jun 2004 07:48:11 -0000	1.12
+++ listview.c	21 Jun 2004 08:47:38 -0000	1.13
@@ -55,7 +55,7 @@
 static int default_column_widths[MAX_LIST_COLUMNS] = { 200, 175, 400 };
 static int column_alignment[MAX_LIST_COLUMNS] = { LVCFMT_LEFT, LVCFMT_LEFT, LVCFMT_LEFT };
 
-LPCTSTR GetValueName(HWND hwndLV)
+LPCTSTR GetValueName(HWND hwndLV, int iStartAt)
 {
     int item, len, maxLen;
     LPTSTR newStr;
@@ -68,7 +68,7 @@
     maxLen = HeapSize(GetProcessHeap(), 0, g_valueName);
     if (maxLen == (SIZE_T) - 1) return NULL;
 
-    item = ListView_GetNextItem(hwndLV, -1, LVNI_FOCUSED | LVNI_SELECTED);
+    item = ListView_GetNextItem(hwndLV, iStartAt, LVNI_SELECTED);
     if (item == -1) return NULL;
     LVItem.mask = LVIF_PARAM;
     LVItem.iItem = item;
@@ -114,7 +114,7 @@
 /*******************************************************************************
  * Local module support methods
  */
-static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValBuf, DWORD dwCount, int Position)
+static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValBuf, DWORD dwCount, int Position, BOOL ValExists)
 {
     LINE_INFO* linfo;
     LVITEM item;
@@ -162,10 +162,17 @@
         switch (dwValType) {
         case REG_SZ:
         case REG_EXPAND_SZ:
-            if(dwCount)
+            if(dwCount > 0)
             {
               ListView_SetItemText(hwndLV, index, 2, ValBuf);
             }
+            else if(!ValExists)
+            {
+              TCHAR buffer[255];
+              /* load (value not set) string */
+              LoadString(hInst, IDS_VALUE_NOT_SET, buffer, sizeof(buffer)/sizeof(TCHAR));
+              ListView_SetItemText(hwndLV, index, 2, buffer);
+            }
             break;
         case REG_MULTI_SZ:
             {
@@ -195,8 +202,15 @@
             }
             break;
         case REG_DWORD: {
-                TCHAR buf[64];
-                wsprintf(buf, _T("0x%08X (%d)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf);
+                TCHAR buf[200];
+                if(dwCount == sizeof(DWORD))
+                {
+                  wsprintf(buf, _T("0x%08X (%d)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf);
+                }
+                else
+                {
+                  LoadString(hInst, IDS_INVALID_DWORD, buf, sizeof(buf)/sizeof(TCHAR));
+                }
                 ListView_SetItemText(hwndLV, index, 2, buf);
             }
             /*            lpsRes = convertHexToDWORDStr(lpbData, dwLen); */
@@ -337,10 +351,6 @@
           }
         }
         break;
-    case 2:
-        LoadString(hInst, IDS_VALUE_NOT_SET, buffer, sizeof(buffer)/sizeof(TCHAR));
-	plvdi->item.pszText = buffer;
-        break;
     case 3:
         plvdi->item.pszText = _T("");
         break;
@@ -499,7 +509,7 @@
         /*                dwValSize = max_val_size; */
         while (RegEnumValue(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) {
             ValBuf[dwValSize] = 0;
-            AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize, -1);
+            AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize, -1, TRUE);
             dwValNameLen = max_val_name_len;
             dwValSize = max_val_size;
             dwValType = 0L;
@@ -514,7 +524,7 @@
     }
     if(!AddedDefault)
     {
-      AddEntryToList(hwndLV, _T(""), REG_SZ, NULL, 0, 0);
+      AddEntryToList(hwndLV, _T(""), REG_SZ, NULL, 0, 0, FALSE);
     }
     ListView_SortItems(hwndLV, CompareFunc, (WPARAM)hwndLV);
     RegCloseKey(hNewKey);

reactos/subsys/system/regedit
main.h 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- main.h	1 Jan 2004 22:29:12 -0000	1.4
+++ main.h	21 Jun 2004 08:47:38 -0000	1.5
@@ -90,7 +90,7 @@
 /* listview.c */
 extern HWND CreateListView(HWND hwndParent, int id);
 extern BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath);
-extern LPCTSTR GetValueName(HWND hwndLV);
+extern LPCTSTR GetValueName(HWND hwndLV, int iStartAt);
 extern BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result);
 extern BOOL IsDefaultValue(HWND hwndLV, int i);
 
@@ -100,6 +100,6 @@
 extern LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
 
 /* edit.c */
-extern BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName);
+extern BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin);
 
 #endif /* __MAIN_H__ */

reactos/subsys/system/regedit
resource.h 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- resource.h	21 Jun 2004 07:48:11 -0000	1.7
+++ resource.h	21 Jun 2004 08:47:38 -0000	1.8
@@ -118,6 +118,12 @@
 #define IDS_MY_COMPUTER			32847
 #define IDS_IMPORT_REG_FILE		32848
 #define IDS_EXPORT_REG_FILE		32849
+#define IDS_INVALID_DWORD		32850
+#define IDS_QUERY_DELETE_ONE		32851
+#define IDS_QUERY_DELETE_MORE		32852
+#define IDS_QUERY_DELETE_CONFIRM	32853
+#define IDS_ERR_DELVAL_CAPTION		32854
+#define IDS_ERR_DELETEVALUE		32855
 
 #define IDS_FLT_REGFILES		31001
 #define IDS_FLT_REGFILES_FLT		31002
CVSspam 0.2.8