SuperPit37
Messages postés61Date d'inscriptionvendredi 1 avril 2005StatutMembreDernière intervention13 novembre 2005
-
30 avril 2005 à 06:12
SuperPit37
Messages postés61Date d'inscriptionvendredi 1 avril 2005StatutMembreDernière intervention13 novembre 2005
-
4 mai 2005 à 23:33
Voila je voudrai que mon appliz se lance au démarage de windows en ajoutant une clef dans la base deregistre, j'ai testé une multitude de code mais y'a toujours un truc qui chit alors ma requete est la suivante est-ce que quelqu'un pourai déposer un code exemple complet en admetant que l'apliz s'appelle test.exe
Je sai que sa fait chier de fair ca pour une seul personne mai sa servira un bien d'autre débutant qui galere avec les api comme moi......
draluorg
Messages postés625Date d'inscriptionvendredi 23 avril 2004StatutMembreDernière intervention25 novembre 2010 30 avril 2005 à 11:48
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...