[RESOLVED] CRegKey::RecursiveDeleteKey() issue
I'm trying a recursive deleting using RecursiveDeleteKey() from CRegKey ATL class. I succeed to get the HKEY valid handler and then using the same path for recursive delete.
Code:
if(RegOpenKeyEx(key, szSubKey, 0, dwAccess, &hKey) == ERROR_SUCCESS)
{
CRegKey key;
key.Attach(hKey);
LONG lRes = key.RecurseDeleteKey(szSubKey);
if (ERROR_SUCCESS != lRes)
{
// FAILL!!!
}
}
I don't understand wky hKey is ok from RegOpenKeyEx() runs ok and RecurseDeleteKey() is not ok.
OS is WinXP SP3 x64 and szSubKey it's a HKEY_CURRENT_USER registry path.
Re: CRegKey::RecursiveDeleteKey() issue
And what is the Last Errror that you get in case of failure ?
Re: CRegKey::RecursiveDeleteKey() issue
Code:
#define ERROR_FILE_NOT_FOUND 2L
:)
I tried to send the path without the last registry key node and that last key node name to pass to RecursiveDeleteKey().
RecursiveDeleteKey() returned ok but the key was not deleted. :confused:
Re: CRegKey::RecursiveDeleteKey() issue
So you got the solution ?
Re: CRegKey::RecursiveDeleteKey() issue
Unfortunately, not yet. I'm still searching...
I tried to call DeleteSubKey() for inside subkey but it returns the same error value.
I'll change the thread's title when I'll find the solution and I'll post it here, too.
Re: CRegKey::RecursiveDeleteKey() issue
If you have the ATL source code installed, you should be able to debug it inside and see what exactly is failing, can you try stepping inside the RecurseDeleteKey once ?
Re: CRegKey::RecursiveDeleteKey() issue
I did it, too. :)
That's how I got the name of constant error code.
Re: CRegKey::RecursiveDeleteKey() issue
Then what function is failing inside the RecurseDeleteKey ?
Re: CRegKey::RecursiveDeleteKey() issue
What are you passing in dwAccess ?
Re: CRegKey::RecursiveDeleteKey() issue
With other tests even if RecursiveDeleteKey(only_key_name_without_path) returned 0 (ERROR_SUCCESS) the key was not remove (has other subkeys). That's why I try to use DeleteSubKey() too.
Debuging into CRegKey::RecurseDeleteKey() I observed that RegEnumKeyEx() didn't returned ERROR_SUCCESS and didn't entered into that while().
I'll be back later with other news. :)
Re: CRegKey::RecursiveDeleteKey() issue
Quote:
Originally Posted by
Krishnaa
What are you passing in dwAccess ?
I pass KEY_ALL_ACCESS.
Re: CRegKey::RecursiveDeleteKey() issue
Can you try isolating the problem in a sample that I can debug in my env ?
Re: CRegKey::RecursiveDeleteKey() issue
There was no issues in my last delete code...
The problem was that after delete operation. That key was regenerated in other project part.
Krishnaa , thanks a lot for your time and energy! :thumb: