Software-OK
≡... News | ... Home | ... FAQ | Impressum | Contact | Listed at | Thank you |

  
HOME ► Faq ► FAQ - Windows-CPP-und-C ► ««« »»»

Alternative to RegDeleteTree!


You can easily write your own routine for RegDeleteTree, or RegDeleteTreeW and RegDeleteTreeA!




Alternatively you can also  use SHDeleteKeyA or  SHDeleteKeyW !
 
The provided C++ code is a function that is used to recursively delete a registry key and all its child keys. Here is a short description of the code with comments in German:


BOOL RecurseDeleteKey(HKEY hKey, LPCTSTR lpszKey)
{
 try
 {
  DWORD dw;
  HKEY hNewKey;
  LONG lRes;
 
  // Attempt to create a new registry key under the provided main key.
  // Using the main key 'hKey' and the key name 'lpszKey'.
  if (RegCreateKeyEx(hKey, (LPCTSTR)lpszKey, 0, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_READ, NULL, &hNewKey, &dw) == ERROR_SUCCESS)
  {
   TCHAR szBuffer[256];
   DWORD dwSize = 256;
   FILETIME time;
 
   // Loop through all subkeys of the newly created key.
   while (RegEnumKeyEx(hNewKey, 0, szBuffer, &dwSize, NULL, NULL, NULL, &time) == ERROR_SUCCESS)
   {
    // Recursive call to delete the subkey.
    lRes = RecurseDeleteKey(hNewKey, szBuffer);
    if (lRes != ERROR_SUCCESS)
     return lRes;
    dwSize = 256;
   }
  }
 
  // Delete the main key and all its subkeys.
  return RegDeleteKey(hKey, lpszKey);
 }
 catch (...)
 {
  return FALSE;
 }
}

This code uses the Windows registry functions to delete registry keys and their child keys. The RecurseDeleteKey function is called recursively to delete all child keys before deleting the master key. Note that the code is wrapped in a try-catch block to catch possible exceptions and return FALSE if an exception occurs.


FAQ 22: Updated on: 4 September 2024 10:20 Windows
Windows-CPP-und-C

ARRAYSIZE Error creating, fix!


Its simple - ARRAYSIZE Error creating, fix error message: : error C2065: ARRAYSIZE : undeclared identifier   Contents: 1. Fixing the ARRAYSIZE error
Windows-CPP-und-C

Replace string for unicode in c++ visual studio!


Often, when transitioning from ANSI to Unicode, you need to replace string literals in your C++ code. This is especially important for making your applications
Windows-CPP-und-C

Difference between _ttof, atof, _atof_l, _wtof, _wtof_l in C++ and C?


Heres the translation and explanation of the differences between _ttof, atof, _atof_l, _wtof, and _wtof_l in C++ and C, focusing on string conversion functions:
Windows-CPP-und-C

Invert color RGB COLORREF InvertColor(COLORREF lColor)!


Heres the translation and explanation of how to invert a color using RGB values and the COLORREF structure with the InvertColor  function: 1. Macros for
Windows-CPP-und-C

Disable / enable MS Visual Studio tabs!


Its easy to disable or re-enable tabs in MS Visual Studio Especially in MS Visual Studio 2008, the tabs cause a window focus problem, but it doesnt hurt
Windows-CPP-und-C

BSCMAKE: error BK1506 : File ... cannot be opened: No such file or directory!


The error message BSCMAKE: error BK1506 : File cannot be opened: No such file or directory Contents: 1. The error message BSCMAKE 2. Other
Windows-CPP-und-C

Difference between script and program?


The main difference is that a script is interpreted while a program is executed  Contents: 1. script vs. program 2. in detail and technically

»»

  My question is not there in the FAQ
Asked questions on this answer:
Keywords: c++, cpp, windows, alternative, regdeletetree, easily, write, your, routine, regdeletetreew, regdeletetreea, alternatively, also, shdeletekeya, shdeletekeyw, Questions, Answers, Software




  

  + Freeware
  + Order on the PC
  + File management
  + Automation
  + Office Tools
  + PC testing tools
  + Decoration and fun
  + Desktop-Clocks
  + Security

  + SoftwareOK Pages
  + Micro Staff
  + Freeware-1
  + Freeware-2
  + Freeware-3
  + FAQ
  + Downloads

  + Top
  + Desktop-OK
  + The Quad Explorer
  + Don't Sleep
  + Win-Scan-2-PDF
  + Quick-Text-Past
  + Print Folder Tree
  + Find Same Images
  + Experience-Index-OK
  + Font-View-OK


  + Freeware
  + DirPrintOK
  + FontViewOK
  + MeinPlatz
  + DesktopOK
  + IsMyMemoryOK
  + StressTheGPU
  + Brightness.Manager.OK
  + ProcessKO
  + WinBin2Iso
  + PAD-s


Home | Thanks | Contact | Link me | FAQ | Settings | Windows 10 | gc24b | English-AV | Impressum | Translate | PayPal | PAD-s

 © 2025 by Nenad Hrg softwareok.de • softwareok.com • softwareok.com • softwareok.eu


► Make Windows-10 Standard User to Guest-Account, how to change rights? ◄
► Don't the protected folders in Windows cause more problems than benefits? ◄
► How to Install Windows 10 or 11 without Product Key? ◄
► Disable Quick Access in Windows 10, 11, 12 Solution or Reg Hack!? ◄


This website does not store personal data. However, third-party providers are used to display ads,
which are managed by Google and comply with the IAB Transparency and Consent Framework (IAB-TCF).
The CMP ID is 300 and can be individually customized at the bottom of the page.
more Infos & Privacy Policy

....