Deletes a key or value from the registry.

Syntax

Status = SRP_Registry("DELETE", Key, ValueName, Value, Error)

Returns

1 if the value was deleted successfully, 0 if there was an error.

Value

The Value parameter is treated as a boolean option. Setting Value to 0 will delete the key only if it has no sub keys. Setting Value to 1 will delete the key and all its sub keys. The default is 0.

Errors

If the service returns 0, then an error occurred. In this event, the Error parameter can be one of the following messages:

ErrorDescription
"Failed to delete key"The key could not delete.
"Failed to create value"The value could not be deleted.
"Failed to open key"The key could not be opened.

Remarks

The DELETE service deletes a key or value from the registry. If you supply both a Key and ValueName, then just the value is deleted and the Key is otherwise left unaltered. If you supply only a Key, leaving the ValueName blank, then the Key and all its values are deleted--with a caveat. If you leave the Value parameter unassigned or set it to 0, then the key is only deleted if it has no sub keys. If you set the value parameter to 1, then the key and all its sub keys and values are deleted. Setting Value to 1 is the surest way to delete a key, but also the most dangeous. Use it with caution. The Value parameter is ignored if ValueName is set.

If you need to delete keys and values more selectively, use the LISTVALUES or LISTKEYS service to enumerate a key's values and sub keys.

Example

* Delete a value from the registry
If SRP_Registry("DELETE", "HKCU\Software\MyApp", "ShowFullscreen", "", Error) EQ 0 then
   Msg(@Window, "DELETE Error: ":Error:@FM:@FM:@FM:4)
end

* Delete a key from the registry only if it doesn't have sub keys
If SRP_Registry("DELETE", "HKCU\Software\MyApp", "", 0, Error) EQ 0 then
   Msg(@Window, "DELETE Error: ":Error:@FM:@FM:@FM:4)
end

* Delete a key from the registry and all its sub keys
If SRP_Registry("DELETE", "HKCU\Software\MyApp", "", 1, Error) EQ 0 then
   Msg(@Window, "DELETE Error: ":Error:@FM:@FM:@FM:4)
end