嘿,我正在尝试从注册表中删除一个密钥,但我似乎无法正确处理。
我的代码如下所示:
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
Run Code Online (Sandbox Code Playgroud)
这棵树看起来像这样: 1
它一直说找不到那个钥匙......任何帮助都会很棒。
大卫
我相信您正在尝试删除子项(“运行”)中的值(“比利”)。
如果是这样,您将需要使用DeleteValue () 方法而不是DeleteSubKey ()。
If Not (foundKey Is Nothing) Then
foundKey.DeleteValue("Billy")
Else
MsgBox("not found")
End If
Run Code Online (Sandbox Code Playgroud)