Lecture base de registre

therafou Messages postés 46 Date d'inscription mercredi 26 février 2003 Statut Membre Dernière intervention 10 juin 2007 - 8 mai 2007 à 22:19
troxsa Messages postés 553 Date d'inscription jeudi 28 novembre 2002 Statut Membre Dernière intervention 2 octobre 2016 - 8 mai 2007 à 23:07
Bonjour,

je viens de trouver un code bien sympa pour lancer un programme directement au démarrage de Windows. Source que j'ai trouvé sur  vbfrance. Donc si je comprends bien le script, il va écrire à un moment donné un clef dans le registre système.
J'aimerai savoir comme vérifier l'état du programme afin de savoir, s'il est déjà en démarrage auto ou pas.
Pour cela je présume qu'il faut aller lire dans la base de registre, mais je ne sais pas trop comment faire.

Si vous avez des pistes ou exemples, Merci d'avance
Bonne soirée à tous

Voilà la partie de code qui permet de mettre en démarage auto ou non
Public Class frmMain
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer. 
    'Do not modify it using the code editor.
    Friend WithEvents btnLanc As System.Windows.Forms.Button
    Friend WithEvents btnSuppr As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btnLanc = New System.Windows.Forms.Button
        Me.btnSuppr = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'btnLanc
        '
        Me.btnLanc.Location = New System.Drawing.Point(8, 8)
        Me.btnLanc.Name = "btnLanc"
        Me.btnLanc.Size = New System.Drawing.Size(224, 32)
        Me.btnLanc.TabIndex = 1
        Me.btnLanc.Text = "Lancement automatique"
        '
        'btnSuppr
        '
        Me.btnSuppr.Location = New System.Drawing.Point(8, 48)
        Me.btnSuppr.Name = "btnSuppr"
        Me.btnSuppr.Size = New System.Drawing.Size(224, 32)
        Me.btnSuppr.TabIndex = 2
        Me.btnSuppr.Text = "Suppression du lancemant automatique"
        '
        'frmMain
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(240, 85)
        Me.Controls.Add(Me.btnSuppr)
        Me.Controls.Add(Me.btnLanc)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.MaximizeBox = False
        Me.Name = "frmMain"
        Me.Text = "Lancement automatique"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub btnLanc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLanc.Click
        Dim regKey As RegistryKey
        Dim ver As Decimal
        regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
        regKey.SetValue("AppTest", Application.ExecutablePath)
        regKey.Close()
        MsgBox("L'application démarrera automatiquement au prochain démarrage de Windows")
    End Sub

    Private Sub btnSuppr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSuppr.Click
        Dim regKey As RegistryKey
        regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
        regKey.DeleteValue("AppTest", True)
        regKey.Close()
        MsgBox("L'application ne démarrera pas automatiquement au prochain démarrage de Windows")
    End Sub
End Class

1 réponse

troxsa Messages postés 553 Date d'inscription jeudi 28 novembre 2002 Statut Membre Dernière intervention 2 octobre 2016 1
8 mai 2007 à 23:07
Salut

http://www.troxsa.info/index.php?option=com_content&task=view&id=30&Itemid=2
J'suis sur en recherchant bien tu trouve des exemples un peux partout sur le net ;)
Cordialement

http://www.troxsa.info/index.php?option=com_content&task=view&id=30&Itemid=2
http://tempuri.org/tempuri.html
http://www.troxsa.info/
Le site qui ne parle qu'un seul langage, visual basic 2005
0
Rejoignez-nous