CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Jan 2003
    Location
    Timisoara, Romania
    Posts
    306

    [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.

  2. #2
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: CRegKey::RecursiveDeleteKey() issue

    And what is the Last Errror that you get in case of failure ?
    Regards,
    Ramkrishna Pawar

  3. #3
    Join Date
    Jan 2003
    Location
    Timisoara, Romania
    Posts
    306

    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.

  4. #4
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: CRegKey::RecursiveDeleteKey() issue

    So you got the solution ?
    Regards,
    Ramkrishna Pawar

  5. #5
    Join Date
    Jan 2003
    Location
    Timisoara, Romania
    Posts
    306

    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.

  6. #6
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    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 ?
    Regards,
    Ramkrishna Pawar

  7. #7
    Join Date
    Jan 2003
    Location
    Timisoara, Romania
    Posts
    306

    Re: CRegKey::RecursiveDeleteKey() issue

    I did it, too.
    That's how I got the name of constant error code.

  8. #8
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: CRegKey::RecursiveDeleteKey() issue

    Then what function is failing inside the RecurseDeleteKey ?
    Regards,
    Ramkrishna Pawar

  9. #9
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: CRegKey::RecursiveDeleteKey() issue

    What are you passing in dwAccess ?
    Regards,
    Ramkrishna Pawar

  10. #10
    Join Date
    Jan 2003
    Location
    Timisoara, Romania
    Posts
    306

    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.

  11. #11
    Join Date
    Jan 2003
    Location
    Timisoara, Romania
    Posts
    306

    Re: CRegKey::RecursiveDeleteKey() issue

    Quote Originally Posted by Krishnaa View Post
    What are you passing in dwAccess ?
    I pass KEY_ALL_ACCESS.

  12. #12
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: CRegKey::RecursiveDeleteKey() issue

    Can you try isolating the problem in a sample that I can debug in my env ?
    Regards,
    Ramkrishna Pawar

  13. #13
    Join Date
    Jan 2003
    Location
    Timisoara, Romania
    Posts
    306

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured