Removing entries out of the registry

Hello,

it’s me again. I’m adding some entries to the Windows registry database:

Dim MyRegistry As RegistryItem 'Title and File are strings. MyRegistry = New RegistryItem("HKEY_CLASSES_ROOT\\.abc",TRUE) MyRegistry.DefaultValue = Title MyRegistry = New RegistryItem("HKEY_CLASSES_ROOT\" + Title,TRUE) MyRegistry.DefaultValue = Title + " " + File MyRegistry.Value("BrowserFlags") = 8 MyRegistry.Value("EditFlags") = 0 MyRegistry = New RegistryItem("HKEY_CLASSES_ROOT\" + Title + "\\shell\\open\\command",TRUE) MyRegistry.DefaultValue = App.ExecutableFile.Parent.Parent.AbsolutePath + "MyProgram.exe %1" MyRegistry = New RegistryItem("HKEY_CLASSES_ROOT\" + Title + "\\DefaultIcon",TRUE) MyRegistry.DefaultValue = App.ExecutableFile.AbsolutePath + ",0"

Well, this is working as intended. But… I haven’t found a method to remove these entries from the registry database. The RB/Xojo language reference is a disastrous… at least not very helpful sometimes (to be polite ;-). So I played around (one full evening) but did not manage getting rid off the registry entries again.

Can you show me an example (using my above stated RegistryItems) that is demonstrating how to remove them ?

Thank you very much for your support. :slight_smile:
Tobias.

Maybe I’m misunderstanding, but did you try the RegistryItem.Delete method? :slight_smile:

Jason, you are a genius. :wink:

Sure, I tried this. But it requires stating the name… but whatever I typed, it did nothing to the registry.

Let’s say, I want to delete this entry:

MyRegistry = New RegistryItem("HKEY_CLASSES_ROOT\" + Title,TRUE) MyRegistry.DefaultValue = Title + " " + File MyRegistry.Value("BrowserFlags") = 8 MyRegistry.Value("EditFlags") = 0

MyRegistry.Delete(“HKEY_CLASSES_ROOT” + Title) -> not working
MyRegistry.Delete(“EditFlags”) -> not working

I also took care that my app runs with administrator rights. But even when turning them off, no exception is raised (although it should).

Likely it’s a small bug on my side, but I can’t find it. Perhaps it’s because I’m tested this on a virtual machine under OS X, but I don’t think that this is the case.

Tobias.

To delete a registry key you need to remove it from it’s parent.

[code]MyRegistry = New RegistryItem(“HKEY_CLASSES_ROOT” + Title,TRUE)
MyRegistry.DefaultValue = Title + " " + File
MyRegistry.Value(“BrowserFlags”) = 8
MyRegistry.Value(“EditFlags”) = 0

Dim myParent As RegistryItem = myRegistryItem.Parent
myParent.Delete(myRegistryItem)
[/code]

This is from memory and should work, but at least it’ll be a pointer.

Thank you, Wayne. I’ll give this a try. :slight_smile: Perhaps it will work.