mirror of
https://github.com/reactos/reactos.git
synced 2025-02-28 19:32:59 +00:00
[ADVAPI32_VISTA] Use RegDeleteTree from reg.c
This commit is contained in:
parent
3dfe367784
commit
90a9171276
3 changed files with 2 additions and 103 deletions
|
@ -1737,6 +1737,7 @@ Cleanup:
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif // _ADVAPI32_VISTA_
|
||||
|
||||
/************************************************************************
|
||||
* RegDeleteTreeW
|
||||
|
@ -1859,6 +1860,7 @@ RegDeleteTreeA(IN HKEY hKey,
|
|||
return Ret;
|
||||
}
|
||||
|
||||
#ifndef _ADVAPI32_VISTA_
|
||||
|
||||
/************************************************************************
|
||||
* RegDisableReflectionKey
|
||||
|
|
|
@ -13,7 +13,6 @@ include_directories(
|
|||
list(APPEND SOURCE
|
||||
DllMain.c
|
||||
../advapi32/reg/reg.c
|
||||
RegDeleteTree.c
|
||||
RegSetKeyValue.c
|
||||
RegLoadMUIString.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/advapi32_vista.def)
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
|
||||
#include "advapi32_vista.h"
|
||||
|
||||
/* heap allocation helpers */
|
||||
static void *heap_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
|
||||
static inline void *heap_alloc( size_t len )
|
||||
{
|
||||
return HeapAlloc( GetProcessHeap(), 0, len );
|
||||
}
|
||||
|
||||
static inline BOOL heap_free( void *mem )
|
||||
{
|
||||
return HeapFree( GetProcessHeap(), 0, mem );
|
||||
}
|
||||
|
||||
/* Taken from Wine advapi32/registry.c */
|
||||
|
||||
/******************************************************************************
|
||||
* RegDeleteTreeW [ADVAPI32.@]
|
||||
*
|
||||
*/
|
||||
LSTATUS WINAPI RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
|
||||
{
|
||||
LONG ret;
|
||||
DWORD dwMaxSubkeyLen, dwMaxValueLen;
|
||||
DWORD dwMaxLen, dwSize;
|
||||
WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
|
||||
HKEY hSubKey = hKey;
|
||||
|
||||
if(lpszSubKey)
|
||||
{
|
||||
ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
|
||||
if (ret) return ret;
|
||||
}
|
||||
|
||||
/* Get highest length for keys, values */
|
||||
ret = RegQueryInfoKeyW(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(WCHAR))
|
||||
{
|
||||
/* Name too big: alloc a buffer for it */
|
||||
if (!(lpszName = heap_alloc( dwMaxLen*sizeof(WCHAR))))
|
||||
{
|
||||
ret = ERROR_NOT_ENOUGH_MEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Recursively delete all the subkeys */
|
||||
while (TRUE)
|
||||
{
|
||||
dwSize = dwMaxLen;
|
||||
if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
|
||||
NULL, NULL, NULL)) break;
|
||||
|
||||
ret = RegDeleteTreeW(hSubKey, lpszName);
|
||||
if (ret) goto cleanup;
|
||||
}
|
||||
|
||||
if (lpszSubKey)
|
||||
ret = RegDeleteKeyW(hKey, lpszSubKey);
|
||||
else
|
||||
while (TRUE)
|
||||
{
|
||||
dwSize = dwMaxLen;
|
||||
if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
|
||||
NULL, NULL, NULL, NULL)) break;
|
||||
|
||||
ret = RegDeleteValueW(hKey, lpszName);
|
||||
if (ret) goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
/* Free buffer if allocated */
|
||||
if (lpszName != szNameBuf)
|
||||
heap_free( lpszName);
|
||||
if(lpszSubKey)
|
||||
RegCloseKey(hSubKey);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* RegDeleteTreeA [ADVAPI32.@]
|
||||
*
|
||||
*/
|
||||
LSTATUS WINAPI RegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
|
||||
{
|
||||
LONG ret;
|
||||
UNICODE_STRING lpszSubKeyW;
|
||||
|
||||
if (lpszSubKey) RtlCreateUnicodeStringFromAsciiz( &lpszSubKeyW, lpszSubKey);
|
||||
else lpszSubKeyW.Buffer = NULL;
|
||||
ret = RegDeleteTreeW( hKey, lpszSubKeyW.Buffer);
|
||||
RtlFreeUnicodeString( &lpszSubKeyW );
|
||||
return ret;
|
||||
}
|
Loading…
Reference in a new issue