Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 149,934 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,493 people online right now. Registration is fast and FREE... Join Now!




cannot delete registry key

 
Reply to this topicStart new topic

cannot delete registry key

rikki_max
13 May, 2008 - 03:01 AM
Post #1

New D.I.C Head
Group Icon

Joined: 18 Apr, 2007
Posts: 42


Dream Kudos: 100
My Contributions
i need to delete a registry key here is my code
CODE

        Dim i As Integer
        i = 1
        Dim ii As Integer
        ii = 1
        Do
            Using key As RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("HKEY_LOCAL_MACHINE\SOFTWARE\frontbridgecomputers\snipba\scripts\" & i, True)
                Do
                    If MsgBox("do you wish to delete " & My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\frontbridgecomputers\snipba\scripts\" & i, ii, "") & "?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                        key.DeleteValue(ii)
                    End If
                    If My.Computer.Registry.LocalMachine.GetValue(ii, "") = "" Then
                        Exit Do
                    End If
                Loop
            End Using
            Dim exists As Boolean = False
            Try
                If My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\frontbridgecomputers\snipba\scripts\" & 1 + 1) IsNot Nothing Then
                    exists = True
                End If
            Finally
                My.Computer.Registry.CurrentUser.Close()
            End Try
            If exists = True Then
                i = i + 1
            Else
                If My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\frontbridgecomputers\snipba\scripts\" & i, ii + 1, "") = Nothing Then
                    Exit Do
                Else
                    ii = ii + 1
                End If
            End If
        Loop

any ideas
here is the whole problem
CODE

key.DeleteValue(ii)


User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Cannot Delete Registry Key
13 May, 2008 - 04:41 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Well sicne you failed to even give the error message you're receiving, read through this tutorial on Wirking with the Windows registry and I think it may come in handy smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 04:00PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month