winecfg: Delete whole AppDefaults\App branch fix[bug 3520]
Vitaliy Margolen
wine-patch at kievinfo.com
Tue Oct 11 21:24:09 CDT 2005
RegDeleteKey does not delete all sub-keys. That's why it was failing to delete
all application settings. This code lifted from regedit with small
modifications.
Vitaliy Margolen
changelog:
winecfg
- Fix "Remove application" for applications that had some custom settings
-------------- next part --------------
Index: programs/winecfg/winecfg.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/winecfg.c,v
retrieving revision 1.39
diff -u -p -r1.39 winecfg.c
--- programs/winecfg/winecfg.c 19 Aug 2005 15:19:10 -0000 1.39
+++ programs/winecfg/winecfg.c 12 Oct 2005 02:16:27 -0000
@@ -189,9 +189,47 @@ static HRESULT remove_value(HKEY root, c
}
/* removes the requested subkey from the registry, assuming it exists */
-static HRESULT remove_path(HKEY root, char *section) {
+static LONG remove_path(HKEY root, char *section) {
+ HKEY branch_key;
+ DWORD max_sub_key_len;
+ DWORD subkeys;
+ DWORD curr_len;
+ LONG ret = ERROR_SUCCESS;
+ long int i;
+ char *buffer;
+
WINE_TRACE("section=%s\n", section);
+ if ((ret = RegOpenKey(root, section, &branch_key)) != ERROR_SUCCESS)
+ return ret;
+
+ /* get size information and resize the buffers if necessary */
+ if ((ret = RegQueryInfoKey(branch_key, NULL, NULL, NULL,
+ &subkeys, &max_sub_key_len,
+ NULL, NULL, NULL, NULL, NULL, NULL
+ )) != ERROR_SUCCESS)
+ return ret;
+
+ curr_len = strlen(section);
+ buffer = HeapAlloc(GetProcessHeap(), 0, max_sub_key_len + curr_len + 1);
+ strcpy(buffer, section);
+
+ buffer[curr_len] = '\\';
+ for (i = subkeys - 1; i >= 0; i--)
+ {
+ DWORD buf_len = max_sub_key_len - curr_len - 1;
+
+ ret = RegEnumKeyEx(branch_key, i, buffer + curr_len + 1,
+ &buf_len, NULL, NULL, NULL, NULL);
+ if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA &&
+ ret != ERROR_NO_MORE_ITEMS)
+ break;
+ else
+ remove_path(root, buffer);
+ }
+ HeapFree(GetProcessHeap(), 0, buffer);
+ RegCloseKey(branch_key);
+
return RegDeleteKey(root, section);
}
More information about the wine-patches
mailing list