regedit: delete key support

Dimitrie O. Paun dpaun at rogers.com
Fri Mar 12 08:50:30 CST 2004


I've changed Attila's patch to use SHDeleteKey.

ChangeLog
    Zimler Attila <hijaszu at hlfslinux.hu>
    Add delete key support for the regedit program.

Index: programs/regedit/En.rc
===================================================================
RCS file: /var/cvs/wine/programs/regedit/En.rc,v
retrieving revision 1.9
diff -u -r1.9 En.rc
--- programs/regedit/En.rc	18 Jan 2004 23:18:33 -0000	1.9
+++ programs/regedit/En.rc	11 Mar 2004 16:44:37 -0000
@@ -228,6 +228,7 @@
 STRINGTABLE DISCARDABLE
 BEGIN
     IDS_ERROR		    "Error"
+    IDS_BAD_KEY		    "Can't query key '%s'"
     IDS_BAD_VALUE           "Can't query value '%s'"
     IDS_UNSUPPORTED_TYPE    "Can't edit keys of this type (%ld)"
     IDS_TOO_BIG_VALUE       "Value is too big (%ld)"
Index: programs/regedit/Makefile.in
===================================================================
RCS file: /var/cvs/wine/programs/regedit/Makefile.in,v
retrieving revision 1.18
diff -u -r1.18 Makefile.in
--- programs/regedit/Makefile.in	9 Mar 2004 04:54:08 -0000	1.18
+++ programs/regedit/Makefile.in	11 Mar 2004 20:12:08 -0000
@@ -5,7 +5,7 @@
 MODULE    = regedit.exe
 APPMODE   = -mwindows
 IMPORTS   = msvcrt advapi32 kernel32
-DELAYIMPORTS = shell32 comdlg32 comctl32 user32 gdi32
+DELAYIMPORTS = shlwapi shell32 comdlg32 comctl32 user32 gdi32
 EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt
 EXTRADEFS = -DNO_LIBWINE_PORT
 
Index: programs/regedit/edit.c
===================================================================
RCS file: /var/cvs/wine/programs/regedit/edit.c,v
retrieving revision 1.11
diff -u -r1.11 edit.c
--- programs/regedit/edit.c	6 Feb 2004 05:16:56 -0000	1.11
+++ programs/regedit/edit.c	12 Mar 2004 14:46:17 -0000
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <shellapi.h>
+#include <shlwapi.h>
 
 #include "main.h"
 #include "regproc.h"
@@ -224,6 +225,30 @@
 done:
     HeapFree(GetProcessHeap(), 0, stringValueData);
     stringValueData = NULL;
+    RegCloseKey(hKey);
+    return result;
+}
+
+BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath)
+{
+    BOOL result = FALSE;
+    LONG lRet;
+    HKEY hKey;
+    
+    lRet = RegOpenKeyEx(hKeyRoot, keyPath, 0, KEY_SET_VALUE, &hKey);
+    if (lRet != ERROR_SUCCESS) return FALSE;
+    
+    if (messagebox(hwnd, MB_YESNO | MB_ICONEXCLAMATION, IDS_DELETE_BOX_TITLE, IDS_DELETE_BOX_TEXT, keyPath) != IDYES)
+	goto done;
+	
+    lRet = SHDeleteKey(hKeyRoot, keyPath);
+    if (lRet != ERROR_SUCCESS) {
+	error(hwnd, IDS_BAD_KEY, keyPath);
+	goto done;
+    }
+    result = TRUE;
+    
+done:
     RegCloseKey(hKey);
     return result;
 }
Index: programs/regedit/framewnd.c
===================================================================
RCS file: /var/cvs/wine/programs/regedit/framewnd.c,v
retrieving revision 1.12
diff -u -r1.12 framewnd.c
--- programs/regedit/framewnd.c	16 Jan 2004 23:02:44 -0000	1.12
+++ programs/regedit/framewnd.c	11 Mar 2004 16:47:00 -0000
@@ -458,8 +458,13 @@
         PrintRegistryHive(hWnd, _T(""));
         break;
     case ID_EDIT_DELETE:
-	if (DeleteValue(hWnd, hKeyRoot, keyPath, valueName))
-	    RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
+	if (GetFocus() == g_pChildWnd->hTreeWnd) {
+	    if (DeleteKey(hWnd, hKeyRoot, keyPath))
+		;/* FIXME: TreeView should be refreshed */
+	} else if (GetFocus() == g_pChildWnd->hListWnd) {
+	    if (DeleteValue(hWnd, hKeyRoot, keyPath, valueName))
+		RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
+	}
         break;
     case ID_EDIT_MODIFY:
         if (ModifyValue(hWnd, hKeyRoot, keyPath, valueName))
@@ -470,6 +475,7 @@
         break;
     case ID_EDIT_NEW_KEY:
 	CreateKey(hWnd, hKeyRoot, keyPath);
+	/* FIXME: TreeView should be refreshed */
 	break;
     case ID_EDIT_NEW_STRINGVALUE:
 	valueType = REG_SZ;
Index: programs/regedit/main.h
===================================================================
RCS file: /var/cvs/wine/programs/regedit/main.h,v
retrieving revision 1.15
diff -u -r1.15 main.h
--- programs/regedit/main.h	16 Jan 2004 23:02:44 -0000	1.15
+++ programs/regedit/main.h	11 Mar 2004 16:45:29 -0000
@@ -91,6 +91,8 @@
 extern BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCTSTR keyPath);
 extern BOOL StartValueRename(HWND hwndLV);
 extern LPCTSTR GetValueName(HWND hwndLV);
+extern BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result);
+extern BOOL IsDefaultValue(HWND hwndLV, int i);
 
 /* treeview.c */
 extern HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id);
@@ -101,6 +103,7 @@
 extern BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath);
 extern BOOL CreateValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, DWORD valueType);
 extern BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName);
+extern BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath);
 extern BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName);
 extern BOOL RenameValue(HWND hwnd, HKEY hRootKey, LPCTSTR keyPath, LPCTSTR oldName, LPCTSTR newName);
 
Index: programs/regedit/resource.h
===================================================================
RCS file: /var/cvs/wine/programs/regedit/resource.h,v
retrieving revision 1.7
diff -u -r1.7 resource.h
--- programs/regedit/resource.h	20 Jan 2004 01:33:02 -0000	1.7
+++ programs/regedit/resource.h	11 Mar 2004 16:45:29 -0000
@@ -117,6 +117,7 @@
 #define IDC_DWORD_DEC			32854
 #define IDS_NEWKEY			32860
 #define IDS_NEWVALUE			32861
+#define IDS_BAD_KEY			32862
 #define ID_EDIT_MODIFY_BIN		32870
 
 #define IDD_EDIT_STRING			2000


-- 
Dimi.




More information about the wine-patches mailing list