delete a registry value

  • Thread starter Thread starter JR
  • Start date Start date
Imports microsoft.win32

Dim oRegKey As RegistryKey
Dim oBaseKey As RegistryKey

oBaseKey = Registry.CurrentUser
oRegKey = oBaseKey.OpenSubKey("Keyname") 'for example ("Software\...")

if not oRegKey is nothing then
oRegKey.DeleteValue("name")
end if

HTH (Ik hoop dat het helpt)
 
I still get the same error

cannot write to the registry

next follows my code

the first 5 lines are for making a new associasion for filetype tbl (my
program's data files) these works fine

than I have a test follow by some test to give permission no error but also
no luck

'-------------------code starts here*-------------------------------

Private Sub mnuAssocieer_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuAssocieer.Click

Dim Reg_ClassRoot As RegistryKey = Registry.ClassesRoot

Dim Reg_CurUser As RegistryKey = Registry.CurrentUser

Dim Reg_Wis As RegistryKey

Dim regPerm1 As RegistryPermission

Const sExplorerDiscription = "WinTabel competitie bestand"

Const sRegistryDiscription = "WinTabel"

Try

Reg_ClassRoot.CreateSubKey(".tbl").SetValue("", sRegistryDiscription)

Reg_ClassRoot.CreateSubKey(sRegistryDiscription).SetValue("",
sExplorerDiscription)

Reg_ClassRoot.CreateSubKey(sRegistryDiscription &
"\DefaultIcon").SetValue("", Application.ExecutablePath & " ,0")

Reg_ClassRoot.CreateSubKey(sRegistryDiscription &
"\shell\open\command").SetValue("", Application.ExecutablePath & " %1")

Reg_Wis =
Reg_CurUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tbl")

If Not Reg_Wis Is Nothing Then

the next 3 lines are new

'regPerm1 = New RegistryPermission(RegistryPermissionAccess.AllAccess,
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tbl")

'regPerm1.AddPathList(RegistryPermissionAccess.AllAccess,
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tbl")

'regPerm1.SetPathList(RegistryPermissionAccess.AllAccess,
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tbl")

Reg_Wis.DeleteValue("Application") 'here is the error

End If

Catch ex As Exception

MsgBox(ex.Message)

End Try

Reg_ClassRoot.Close()

Reg_CurUser.Close()

End Sub 'mnuAssocieer_Click

'-------------------code ends here*-------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top