advapi32: Implemented RegDeleteKeyExA/W.

This commit is contained in:
Alexandre Julliard 2010-02-18 13:12:31 +01:00
parent 8543c32442
commit 9b7d1041fc
3 changed files with 54 additions and 29 deletions

View File

@ -472,6 +472,8 @@
@ stdcall RegCreateKeyExW(long wstr long ptr long long ptr ptr ptr) @ stdcall RegCreateKeyExW(long wstr long ptr long long ptr ptr ptr)
@ stdcall RegCreateKeyW(long wstr ptr) @ stdcall RegCreateKeyW(long wstr ptr)
@ stdcall RegDeleteKeyA(long str) @ stdcall RegDeleteKeyA(long str)
@ stdcall RegDeleteKeyExA(long str long long)
@ stdcall RegDeleteKeyExW(long wstr long long)
@ stdcall RegDeleteKeyW(long wstr) @ stdcall RegDeleteKeyW(long wstr)
@ stdcall RegDeleteTreeA(long str) @ stdcall RegDeleteTreeA(long str)
@ stdcall RegDeleteTreeW(long wstr) @ stdcall RegDeleteTreeW(long wstr)

View File

@ -931,11 +931,9 @@ LSTATUS WINAPI RegCloseKey( HKEY hkey )
/****************************************************************************** /******************************************************************************
* RegDeleteKeyW [ADVAPI32.@] * RegDeleteKeyExW [ADVAPI32.@]
*
* See RegDeleteKeyA.
*/ */
LSTATUS WINAPI RegDeleteKeyW( HKEY hkey, LPCWSTR name ) LSTATUS WINAPI RegDeleteKeyExW( HKEY hkey, LPCWSTR name, REGSAM access, DWORD reserved )
{ {
DWORD ret; DWORD ret;
HKEY tmp; HKEY tmp;
@ -944,7 +942,8 @@ LSTATUS WINAPI RegDeleteKeyW( HKEY hkey, LPCWSTR name )
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE; if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
if (!(ret = RegOpenKeyExW( hkey, name, 0, DELETE, &tmp ))) access &= KEY_WOW64_64KEY | KEY_WOW64_32KEY;
if (!(ret = RegOpenKeyExW( hkey, name, 0, access | DELETE, &tmp )))
{ {
ret = RtlNtStatusToDosError( NtDeleteKey( tmp ) ); ret = RtlNtStatusToDosError( NtDeleteKey( tmp ) );
RegCloseKey( tmp ); RegCloseKey( tmp );
@ -954,6 +953,50 @@ LSTATUS WINAPI RegDeleteKeyW( HKEY hkey, LPCWSTR name )
} }
/******************************************************************************
* RegDeleteKeyW [ADVAPI32.@]
*
* See RegDeleteKeyA.
*/
LSTATUS WINAPI RegDeleteKeyW( HKEY hkey, LPCWSTR name )
{
return RegDeleteKeyExW( hkey, name, 0, 0 );
}
/******************************************************************************
* RegDeleteKeyExA [ADVAPI32.@]
*/
LSTATUS WINAPI RegDeleteKeyExA( HKEY hkey, LPCSTR name, REGSAM access, DWORD reserved )
{
DWORD ret;
HKEY tmp;
if (!name) return ERROR_INVALID_PARAMETER;
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
access &= KEY_WOW64_64KEY | KEY_WOW64_32KEY;
if (!(ret = RegOpenKeyExA( hkey, name, 0, access | DELETE, &tmp )))
{
if (!is_version_nt()) /* win95 does recursive key deletes */
{
CHAR name[MAX_PATH];
while(!RegEnumKeyA(tmp, 0, name, sizeof(name)))
{
if(RegDeleteKeyExA(tmp, name, access, reserved)) /* recurse */
break;
}
}
ret = RtlNtStatusToDosError( NtDeleteKey( tmp ) );
RegCloseKey( tmp );
}
TRACE("%s ret=%08x\n", debugstr_a(name), ret);
return ret;
}
/****************************************************************************** /******************************************************************************
* RegDeleteKeyA [ADVAPI32.@] * RegDeleteKeyA [ADVAPI32.@]
* *
@ -974,30 +1017,7 @@ LSTATUS WINAPI RegDeleteKeyW( HKEY hkey, LPCWSTR name )
*/ */
LSTATUS WINAPI RegDeleteKeyA( HKEY hkey, LPCSTR name ) LSTATUS WINAPI RegDeleteKeyA( HKEY hkey, LPCSTR name )
{ {
DWORD ret; return RegDeleteKeyExA( hkey, name, 0, 0 );
HKEY tmp;
if (!name) return ERROR_INVALID_PARAMETER;
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
if (!(ret = RegOpenKeyExA( hkey, name, 0, DELETE, &tmp )))
{
if (!is_version_nt()) /* win95 does recursive key deletes */
{
CHAR name[MAX_PATH];
while(!RegEnumKeyA(tmp, 0, name, sizeof(name)))
{
if(RegDeleteKeyA(tmp, name)) /* recurse */
break;
}
}
ret = RtlNtStatusToDosError( NtDeleteKey( tmp ) );
RegCloseKey( tmp );
}
TRACE("%s ret=%08x\n", debugstr_a(name), ret);
return ret;
} }

View File

@ -104,6 +104,9 @@ WINADVAPI LSTATUS WINAPI RegCreateKeyExW(HKEY,LPCWSTR,DWORD,LPWSTR,DWORD,REGSA
WINADVAPI LSTATUS WINAPI RegDeleteKeyA(HKEY,LPCSTR); WINADVAPI LSTATUS WINAPI RegDeleteKeyA(HKEY,LPCSTR);
WINADVAPI LSTATUS WINAPI RegDeleteKeyW(HKEY,LPCWSTR); WINADVAPI LSTATUS WINAPI RegDeleteKeyW(HKEY,LPCWSTR);
#define RegDeleteKey WINELIB_NAME_AW(RegDeleteKey) #define RegDeleteKey WINELIB_NAME_AW(RegDeleteKey)
WINADVAPI LSTATUS WINAPI RegDeleteKeyExA(HKEY,LPCSTR,REGSAM,DWORD);
WINADVAPI LSTATUS WINAPI RegDeleteKeyExW(HKEY,LPCWSTR,REGSAM,DWORD);
#define RegDeleteKeyEx WINELIB_NAME_AW(RegDeleteKeyEx)
WINADVAPI LSTATUS WINAPI RegDeleteKeyValueA(HKEY,LPCSTR,LPCSTR); WINADVAPI LSTATUS WINAPI RegDeleteKeyValueA(HKEY,LPCSTR,LPCSTR);
WINADVAPI LSTATUS WINAPI RegDeleteKeyValueW(HKEY,LPCWSTR,LPCWSTR); WINADVAPI LSTATUS WINAPI RegDeleteKeyValueW(HKEY,LPCWSTR,LPCWSTR);
#define RegDeleteKeyValue WINELIB_NAME_AW(RegDeleteKeyValue) #define RegDeleteKeyValue WINELIB_NAME_AW(RegDeleteKeyValue)