Dim Cle As RegistryKey = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run") Cle.SetValue("Compteur", My.Application.Info.DirectoryPath & "\Compteur.exe", RegistryValueKind.String)
Dim value As String value = Microsoft.Win32.Registry.CurrentUser.GetValue("Software\\Microsoft\\Windows\\CurrentVersion\\Run\\Compteur") If value IsNot Nothing Then MsgBox("la clé existe") Else MsgBox("la clé n'existe pas") End If
Dim test As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run\Compteur",False)
If test Is Nothing Then
MsgBox("la clé existe")
Else
MsgBox("la clé n'existe pas")
End If
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", True) Dim value = key.GetValue("compteur") If value Is Nothing Then key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run") key.SetValue("Compteur", My.Application.Info.DirectoryPath & "\Compteur.exe", RegistryValueKind.String) key.Close() Me.DémarrageAutoToolStripMenuItem.Text = "&Désactiver" Else key.DeleteValue("Compteur") Me.DémarrageAutoToolStripMenuItem.Text = "&Activer" End If