嘿所有我想从注册表中删除一个密钥,但我似乎无法将其弄清楚。
我的代码如下所示:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim tmpKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
Dim foundKey As RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey(tmpKey, True)
If Not (foundKey Is Nothing) Then
foundKey.DeleteSubKey("Billy")
Else
MsgBox("not found")
End If
End Sub
树看起来像这样: 1
它一直说它无法找到那把钥匙......任何帮助都会很棒。
大卫
答案 0 :(得分:4)
我相信你试图在子项中删除一个值(" Billy")(" Run")。
如果是这样,您需要使用 DeleteValue ()方法而不是 DeleteSubKey ()。
If Not (foundKey Is Nothing) Then
foundKey.DeleteValue("Billy")
Else
MsgBox("not found")
End If