I have created an application with 2 buttons. Button 1 adds application as startup in current user.
Button 2 should remove the registry key. However i'm not sure of the code to remove the key. Can anyone help?
My code:
Thanks.
Button 2 should remove the registry key. However i'm not sure of the code to remove the key. Can anyone help?
My code:
Code:
Imports Microsoft.Win32
Public Class Mainform
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim regStartUp As RegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
Dim value As String
value = regStartUp.GetValue("Myapp")
If value <> Application.ExecutablePath.ToString() Then
regStartUp.CreateSubKey("Myapp")
regStartUp.SetValue("Myapp", Application.ExecutablePath.ToString())
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
End Sub
End Class