Probleme VALEUR REG_DWORD

browser64 Messages postés 112 Date d'inscription dimanche 24 avril 2005 Statut Membre Dernière intervention 5 décembre 2010 - 23 juin 2006 à 01:59
Dolphin Boy Messages postés 630 Date d'inscription vendredi 5 mai 2006 Statut Membre Dernière intervention 17 février 2007 - 23 juin 2006 à 08:52
Salut a tous, voici mon code ou je rencontre un probleme car ne n'arrive pas a écrire ma valeur qui s'appelle FLUNCH voir source en bas. OU EST LE BLEME ?????

Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_CURRENT_CONFIG = &H80000005
Const REG_DWORD = 4
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (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




Function RegCreationDWORD(HkeyRoot As Long, sKey As String, Svalue As String, V As Long) As Boolean


X = RegCreationDWORD(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", "Flunch", 1)
Dim F As Long, Hkey As Long
If RegOpenKey(HkeyRoot, sKey, Hkey) <> 0 Then
RegCreationDWORD = False
Exit Function
End If
F = RegSetValueEx(Hkey, Svalue, 0&, REG_DWORD, V, ByVal REG_DWORD)
RegCloseKey Hkey
RegCreationDWORD = True
End Function

2 réponses

Dolphin Boy Messages postés 630 Date d'inscription vendredi 5 mai 2006 Statut Membre Dernière intervention 17 février 2007
23 juin 2006 à 08:35
Salut, à quoi sert le X = .... ? à rentrer dans une boucle récursive interminable ?
0
Dolphin Boy Messages postés 630 Date d'inscription vendredi 5 mai 2006 Statut Membre Dernière intervention 17 février 2007
23 juin 2006 à 08:52
Voilà comment je fais pour inscrire ta valeur dans la BDR, j'utilise RegCreateKey au lieu de RegOpenKey, ainsi la clé est crée si elle n'existe pas ou modifiée si elle existe :

Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_CURRENT_CONFIG = &H80000005
Const REG_DWORD = 4
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


Function RegCreationDWORD(HkeyRoot As Long, sKey As String, Svalue As String, V As Long)
Dim Keyhand As Long
    Call RegCreateKey(HkeyRoot, sKey, Keyhand)
    Call RegSetValueEx(Keyhand, Svalue, 0&, REG_DWORD, V, REG_DWORD)
    Call RegCloseKey(Keyhand)
End Function

'Pour appeler la fonction dans ton code :
Call RegCreationDWORD(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", "Flunch", 1)


 
0
Rejoignez-nous