Francois Gouget : comctl32/tests: Avoid SHDeleteKeyA() because it does not exist on Windows 95.
Alexandre Julliard
julliard at winehq.org
Mon Dec 10 08:54:21 CST 2007
Module: wine
Branch: master
Commit: b7ae831f00d587de802224d8ef839376485bba73
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b7ae831f00d587de802224d8ef839376485bba73
Author: Francois Gouget <fgouget at free.fr>
Date: Mon Dec 10 01:28:08 2007 +0100
comctl32/tests: Avoid SHDeleteKeyA() because it does not exist on Windows 95.
---
dlls/comctl32/tests/Makefile.in | 2 +-
dlls/comctl32/tests/mru.c | 69 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/tests/Makefile.in b/dlls/comctl32/tests/Makefile.in
index 17583cf..45bd219 100644
--- a/dlls/comctl32/tests/Makefile.in
+++ b/dlls/comctl32/tests/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = comctl32.dll
-IMPORTS = comctl32 ole32 shlwapi user32 gdi32 advapi32 kernel32
+IMPORTS = comctl32 ole32 user32 gdi32 advapi32 kernel32
CTESTS = \
comboex.c \
diff --git a/dlls/comctl32/tests/mru.c b/dlls/comctl32/tests/mru.c
index cf42e9e..d5e1d8a 100644
--- a/dlls/comctl32/tests/mru.c
+++ b/dlls/comctl32/tests/mru.c
@@ -74,6 +74,73 @@ static INT (WINAPI *pFindMRUStringA)(HANDLE,LPCSTR,LPINT);
*/
+/* Based on RegDeleteTreeW from dlls/advapi32/registry.c */
+static LSTATUS mru_RegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
+{
+ LONG ret;
+ DWORD dwMaxSubkeyLen, dwMaxValueLen;
+ DWORD dwMaxLen, dwSize;
+ CHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
+ HKEY hSubKey = hKey;
+
+ if(lpszSubKey)
+ {
+ ret = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
+ if (ret) return ret;
+ }
+
+ /* Get highest length for keys, values */
+ ret = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, NULL,
+ &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
+ if (ret) goto cleanup;
+
+ dwMaxSubkeyLen++;
+ dwMaxValueLen++;
+ dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
+ if (dwMaxLen > sizeof(szNameBuf)/sizeof(CHAR))
+ {
+ /* Name too big: alloc a buffer for it */
+ if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(CHAR))))
+ {
+ ret = ERROR_NOT_ENOUGH_MEMORY;
+ goto cleanup;
+ }
+ }
+
+
+ /* Recursively delete all the subkeys */
+ while (TRUE)
+ {
+ dwSize = dwMaxLen;
+ if (RegEnumKeyExA(hSubKey, 0, lpszName, &dwSize, NULL,
+ NULL, NULL, NULL)) break;
+
+ ret = mru_RegDeleteTreeA(hSubKey, lpszName);
+ if (ret) goto cleanup;
+ }
+
+ if (lpszSubKey)
+ ret = RegDeleteKeyA(hKey, lpszSubKey);
+ else
+ while (TRUE)
+ {
+ dwSize = dwMaxLen;
+ if (RegEnumValueA(hKey, 0, lpszName, &dwSize,
+ NULL, NULL, NULL, NULL)) break;
+
+ ret = RegDeleteValueA(hKey, lpszName);
+ if (ret) goto cleanup;
+ }
+
+cleanup:
+ /* Free buffer if allocated */
+ if (lpszName != szNameBuf)
+ HeapFree( GetProcessHeap(), 0, lpszName);
+ if(lpszSubKey)
+ RegCloseKey(hSubKey);
+ return ret;
+}
+
static BOOL create_reg_entries(void)
{
HKEY hKey = NULL;
@@ -92,7 +159,7 @@ static void delete_reg_entries(void)
if (RegOpenKeyExA(HKEY_CURRENT_USER, REG_TEST_BASEKEYA, 0, KEY_ALL_ACCESS,
&hKey))
return;
- SHDeleteKeyA(hKey, REG_TEST_BASESUBKEYA);
+ mru_RegDeleteTreeA(hKey, REG_TEST_BASESUBKEYA);
RegCloseKey(hKey);
}
More information about the wine-cvs
mailing list