Valhalla Legends Archive

Programming => General Programming => Topic started by: WolfSage on January 20, 2003, 02:50 PM

Title: Windows Registry
Post by: WolfSage on January 20, 2003, 02:50 PM
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.
Title: Re: Windows Registry
Post by: Etheran on January 20, 2003, 04:55 PM
Post the code you're using.
Title: Re: Windows Registry
Post by: Skywing on January 21, 2003, 07:55 AM
Does the registry key have any subkeys?  RegDeleteKey will only delete keys without any subkeys in NT/2K/XP.
Title: Re: Windows Registry
Post by: Grok on January 21, 2003, 08:23 AM
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.

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.
Title: Re: Windows Registry
Post by: WolfSage on January 21, 2003, 10:59 AM
Thank you very much Sky and Grok. Knew I could count on you. :)
Title: Re: Windows Registry
Post by: Wolf on January 27, 2003, 12:04 PM
I dunno if this is any help but http://www.pscode.com has some stuff about regestry editing
Title: Re: Windows Registry
Post by: WolfSage on January 27, 2003, 04:58 PM
Heh, everyone refers to that page it seems. I got it under control though. Thanks ~