Add delete key support.
diff --git a/programs/regedit/En.rc b/programs/regedit/En.rc
index af0465a..804e521 100644
--- a/programs/regedit/En.rc
+++ b/programs/regedit/En.rc
@@ -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)"
diff --git a/programs/regedit/Makefile.in b/programs/regedit/Makefile.in
index 2c6c64e..7d54c28 100644
--- a/programs/regedit/Makefile.in
+++ b/programs/regedit/Makefile.in
@@ -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
diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c
index 079e9dc..7b11fc5 100644
--- a/programs/regedit/edit.c
+++ b/programs/regedit/edit.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <shellapi.h>
+#include <shlwapi.h>
#include "main.h"
#include "regproc.h"
@@ -228,6 +229,30 @@
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;
+}
+
BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName)
{
BOOL result = FALSE;
diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c
index faec4f1..ad69178 100644
--- a/programs/regedit/framewnd.c
+++ b/programs/regedit/framewnd.c
@@ -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;
diff --git a/programs/regedit/main.h b/programs/regedit/main.h
index 6c7ca6d..e4ad963 100644
--- a/programs/regedit/main.h
+++ b/programs/regedit/main.h
@@ -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);
diff --git a/programs/regedit/resource.h b/programs/regedit/resource.h
index 3cc1bd1..87e8482 100644
--- a/programs/regedit/resource.h
+++ b/programs/regedit/resource.h
@@ -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