• Welcome to Valhalla Legends Archive.
 

Windows Registry

Started by WolfSage, January 20, 2003, 02:50 PM

Previous topic - Next topic

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.

Etheran

#1
Post the code you're using.

Skywing

#2
Does the registry key have any subkeys?  RegDeleteKey will only delete keys without any subkeys in NT/2K/XP.

Grok

#3
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.

WolfSage

#4
Thank you very much Sky and Grok. Knew I could count on you. :)

Wolf

#5
I dunno if this is any help but http://www.pscode.com has some stuff about regestry editing
Seen as +i!+Wolf+i!+, (i!)~Wolf~(i!)

WolfSage

#6
Heh, everyone refers to that page it seems. I got it under control though. Thanks ~