Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 220407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:56:09+00:00 2026-05-11T18:56:09+00:00

I need to remove a subtree in the Windows registry under Windows Mobile 6.

  • 0

I need to remove a subtree in the Windows registry under Windows Mobile 6. The RegDeleteTree function is not available, and SHDeleteKey is (apparently) not available in any static library under the WM6 SDK, though the declaration is available in shlwapi.h.
I tried to get it from shlwapi.dll, like

    typedef DWORD (__stdcall *SHDeleteKey_Proc) (HKEY, LPCWSTR);
    SHDeleteKey_Proc procSHDeleteKey; 
    HINSTANCE shlwapidll = ::LoadLibrary(_T("shlwapi.dll"));
    if(shlwapidll) {
    procSHDeleteKey = 
            (SHDeleteKey_Proc)GetProcAddress(shlwapidll,_T("SHDeleteKeyW"));
        ASSERT(procSHDeleteKey);
    }

But I hit the assert.
Is there a nice way to delete, recursively, a Registry key (empty or not) under Windows Mobile?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:56:09+00:00Added an answer on May 11, 2026 at 6:56 pm

    I guess I found the answer myself in MSDN. It puzzles me that the functionality is not available through the SDK, though…
    I put the code from MSDN here as well, just for the record:

    //*************************************************************
    //
    //  RegDelnodeRecurse()
    //
    //  Purpose:    Deletes a registry key and all it's subkeys / values.
    //
    //  Parameters: hKeyRoot    -   Root key
    //              lpSubKey    -   SubKey to delete
    //
    //  Return:     TRUE if successful.
    //              FALSE if an error occurs.
    //
    //*************************************************************
    
    BOOL RegDelnodeRecurse (HKEY hKeyRoot, LPTSTR lpSubKey)
    {
        LPTSTR lpEnd;
        LONG lResult;
        DWORD dwSize;
        TCHAR szName[MAX_PATH];
        HKEY hKey;
        FILETIME ftWrite;
    
        // First, see if we can delete the key without having
        // to recurse.
    
        lResult = RegDeleteKey(hKeyRoot, lpSubKey);
    
        if (lResult == ERROR_SUCCESS) 
            return TRUE;
    
        lResult = RegOpenKeyEx (hKeyRoot, lpSubKey, 0, KEY_READ, &hKey);
    
        if (lResult != ERROR_SUCCESS) 
        {
            if (lResult == ERROR_FILE_NOT_FOUND) {
                printf("Key not found.\n");
                return TRUE;
            } 
            else {
                printf("Error opening key.\n");
                return FALSE;
            }
        }
    
        // Check for an ending slash and add one if it is missing.
    
        lpEnd = lpSubKey + lstrlen(lpSubKey);
    
        if (*(lpEnd - 1) != TEXT('\\')) 
        {
            *lpEnd =  TEXT('\\');
            lpEnd++;
            *lpEnd =  TEXT('\0');
        }
    
        // Enumerate the keys
    
        dwSize = MAX_PATH;
        lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL,
                               NULL, NULL, &ftWrite);
    
        if (lResult == ERROR_SUCCESS) 
        {
            do {
    
                StringCchCopy (lpEnd, MAX_PATH*2, szName);
    
                if (!RegDelnodeRecurse(hKeyRoot, lpSubKey)) {
                    break;
                }
    
                dwSize = MAX_PATH;
    
                lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL,
                                       NULL, NULL, &ftWrite);
    
            } while (lResult == ERROR_SUCCESS);
        }
    
        lpEnd--;
        *lpEnd = TEXT('\0');
    
        RegCloseKey (hKey);
    
        // Try again to delete the key.
    
        lResult = RegDeleteKey(hKeyRoot, lpSubKey);
    
        if (lResult == ERROR_SUCCESS) 
            return TRUE;
    
        return FALSE;
    }
    
    //*************************************************************
    //
    //  RegDelnode()
    //
    //  Purpose:    Deletes a registry key and all it's subkeys / values.
    //
    //  Parameters: hKeyRoot    -   Root key
    //              lpSubKey    -   SubKey to delete
    //
    //  Return:     TRUE if successful.
    //              FALSE if an error occurs.
    //
    //*************************************************************
    
    BOOL RegDelnode (HKEY hKeyRoot, LPTSTR lpSubKey)
    {
        TCHAR szDelKey[MAX_PATH*2];
    
        StringCchCopy (szDelKey, MAX_PATH*2, lpSubKey);
        return RegDelnodeRecurse(hKeyRoot, szDelKey);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.