Valhalla Legends Forums Archive | General Programming | Windows Registry

AuthorMessageTime
WolfSage
I am having a problem with the registry I can't seem to figure out. I can't seem to delete a registry key from my program. I've done it like MSDN says, yet it doesn't work. Any help would be appreciated.
January 20, 2003, 8:50 PM
Etheran
Post the code you're using.
January 20, 2003, 10:55 PM
Skywing
Does the registry key have any subkeys?  RegDeleteKey will only delete keys without any subkeys in NT/2K/XP.
January 21, 2003, 1:55 PM
Grok
As Skywing said:

The RegDeleteKey function deletes a subkey.

Windows 95/98/Me: The function also deletes all subkeys and values. To delete a key only if the key has no subkeys or values, use the SHDeleteEmptyKey function.

Windows NT/2000/XP: The subkey to be deleted must not have subkeys. To delete a key and all its subkeys, you need to recursively enumerate the subkeys and delete them individually.

To recursively delete keys, use the SHDeleteKey function.
[pre]
SHDeleteKey


Deletes a subkey and all its descendants. The function will remove the key and all of the key's values from the registry.

DWORD SHDeleteKey(
   HKEY     hkey,
   LPCTSTR  pszSubKey
   );

Parameters
hkey
Handle to the currently open key, or any of the following predefined values:
   HKEY_CLASSES_ROOT
   HKEY_CURRENT_CONFIG
   HKEY_CURRENT_USER
   HKEY_DYN_DATA (Windows 95 only)
   HKEY_LOCAL_MACHINE
   HKEY_PERFORMANCE_DATA (Windows NT only)
   HKEY_USERS

pszSubKey
   Address of a null-terminated string specifying the name of the key to delete.
[/pre]
January 21, 2003, 2:23 PM
WolfSage
Thank you very much Sky and Grok. Knew I could count on you. :)
January 21, 2003, 4:59 PM
Wolf
I dunno if this is any help but http://www.pscode.com has some stuff about regestry editing
January 27, 2003, 6:04 PM
WolfSage
Heh, everyone refers to that page it seems. I got it under control though. Thanks ~
January 27, 2003, 10:58 PM

Search