Extensions Reference

Extensions Reference > exRegistry


regDeleteKey

bool regDeleteKey(string Hive, string Key);

 

Deletes an existing registry key

The REGDELETEKEY function deletes the specified key in the specified hive, along with all its values. If any registry key is already open (by using exRegistry::regOpenKey or exRegistry::regCreateKey), the key is first closed. This is done as REGDELETEKEY has no simple or fast way to verify that the open key isn't a subkey of the key targeted for deletion (an open key would cause REGDELETEKEY to fail). Therefore if you wish to perform further registry operations after calling REGDELETEKEY you must reopen the target registry key after REGDELETEKEY has been called. This is true regardless of whether the deletion succeeded or failed.

 

Parameters

Hive

The name of the registry hive you wish to open. Short names and long names are both valid and must be one of:

Short name Long name
HKCR HKEY_CLASSES_ROOT
HKCU HKEY_CURRENT_USER
HKLM HKEY_LOCAL_MACHINE
HKCC HKEY_CURRENT_CONFIG
HKU HKEY_USERS
HKPD HKEY_PERFORMANCE_DATA

Key

The name of the key you wish to delete. Keys can be specified as paths, for example if the MyPlugin key is a subkey of Plugins, and Plugins is a subkey of Software, you would specify the key as "Software\\Plugins\\MyPlugin". Remember to use escaped double backslashes.

 

Return Value

True if the deletion was successful.

 

Example Code

// Delete the Brass registry key for the current user.
if(regDeleteKey("HKCU", "Software\\32Bits\\Brass") == True)
{
    // If we want to do any more registry work we must call
    // regOpenKey or regCreateKey again
}