Réponse acceptée !
Salut,
tout d'abord ouvre un nouveau projet et ajoute lui un module,
puis dans ce module copie ce code:
Option Explicit
Const REG_SZ = 1
Const ERROR_SUCCESS = 0&
Public Const HKCU = &H80000001
Public Const HKLM = &H80000002
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Sub EcrireChaine(Racin As Long, strPath As String, strValue As String, strData As String)
Dim Ret
Dim ErCode
RegCreateKey Racin, strPath, Ret
RegSetValueEx Ret, strValue, 0, REG_SZ, ByVal strData, Len(strData)
If ErCode <> ERROR_SUCCESS Then MsgBox ErCode
RegCloseKey Ret
End Sub
Public Function GetExePath()
Dim Chemin As String
Dim NomProg As String
Chemin = App.Path
NomProg = App.EXEName & ".exe"
If Right$(Chemin, 1) = "\" Then _
GetExePath = Chemin & NomProg Else _
GetExePath = Chemin & "\" & NomProg
DoEvents
End Function
Puis tu n'a plus qu'a ecrire ceci ou tu veux dant ton programe
' Seulement l'utilisateur courrant:
EcrireChaine HKCU, "Software\Microsoft\Windows\CurrentVersion\Run", App.EXEName, GetExePath
' Tous les utilisateurs
EcrireChaine HKLM, "Software\Microsoft\Windows\CurrentVersion\Run", App.EXEName, GetExePath
Le programme s'enregistreera directement sous le nom k'il porte avec et l'endroit ou il se trouve ;)
Quand on pose une question on est con 5 minutes,
Quand on ne la pose pas on le reste toute sa vie...