Search code examples
vb.netregistry

How to delete range of values of a registery subkey


I am trying to delete IE history of typed links. I found this VB6 code but I want it in VB.Net. Any help please?

Function Typed()
    For i = 1 To 100
        se = RGGetKeyValue(HKEY_CURRENT_USER, "Software\Microsoft\InternetExplorer\TypedURLs\", "url" & i)
        If se <> "" Then List1.AddItem se: List1.ListIndex = List1.ListCount - 1
        DeleteValue HKEY_CURRENT_USER, "Software\Microsoft\Internet  Explorer\TypedURLs\", "url" & i
    Next
End Function

Solution

  • in .NET its easier...

    Sub Typed()
        'get a reference to the registry key
        Dim regKey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Internet Explorer\TypedURLs", True)
    
        ' enumerate the list of values under that registry key
        For Each value In regKey.GetValueNames
            ' add to listbox
            ListBox1.Items.Add(regKey.GetValue(value))
            ' delete the value from registry
            regKey.DeleteValue(value)
        Next
    End Sub