How to: Delete a Registry Key in Visual Basic
To delete a registry key
Use the DeleteSubKey method to delete a registry key. This example deletes the key Software/TestApp in the CurrentUser hive. You can change this in the code to the appropriate string, or have it rely on user-supplied information.
The DeleteSubKey method returns an empty string if the key/value pair does not exist.
The following conditions may cause an exception:
Registry calls fail if either sufficient run-time permissions are not granted (RegistryPermission) or if the user does not have the correct access (as determined by the ACLs) for creating or writing to settings. For example, a local application that has the code access security permission might not have operating system permission.