Suprimer un clef!

Résolu
marko04 Messages postés 7 Date d'inscription lundi 21 juin 2004 Statut Membre Dernière intervention 14 mars 2005 - 1 sept. 2004 à 00:03
bilaloch Messages postés 556 Date d'inscription lundi 6 octobre 2003 Statut Membre Dernière intervention 31 octobre 2019 - 1 sept. 2004 à 12:15
Comment l'ont peux suprimer une clef (Par Vb car ces simple par regedit) quand la clef est :

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\Clef

Et une facons que les antivirus ne capote pas car j'ai entendu parler que les antivirus pouvais donner alerte lorsque une clef ce suprime :| tk merci bien de me répondre

4 réponses

Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
1 sept. 2004 à 02:40
Option Explicit

Const REG_SZ = 1 ' Unicode nul terminated String

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

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 RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long

Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long

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 Enum HKeyTypes
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
HKEY_PERFORMANCE_DATA = &H80000004
End Enum

Private Sub Form_Load()
Dim ProgramName As String
Dim FileToRun As String
Dim StrPath As String

ProgramName = "Dan Antipub11"
FileToRun = "C:\VB1\Danpub11.exe"
StrPath = "Software\Microsoft\Windows\CurrentVersion\Run"

' Add a program to the 'Run at Startup'
' Call SaveString(HKEY_LOCAL_MACHINE, StrPath, ProgramName, FileToRun)

' Remove a program from the 'Run at Start
Call DeleteValue(HKEY_LOCAL_MACHINE, StrPath, ProgramName)

End Sub

Private Sub SaveString(hKey As HKeyTypes, StrPath As String, strValue As String, strdata As String)
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(hKey, StrPath, keyhand)
Text1 = r
r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata))
Text2 = r
r = RegCloseKey(keyhand)
Text3 = r
End Sub

Private Function DeleteValue(ByVal hKey As HKeyTypes, ByVal StrPath As String, ByVal strValue As String)
Dim keyhand As Long
Dim r As Long
r = RegOpenKey(hKey, StrPath, keyhand)
Text1 = r
r = RegDeleteValue(keyhand, strValue)
Text2 = r
r = RegCloseKey(keyhand)
Text3 = r
End Function
3
bilaloch Messages postés 556 Date d'inscription lundi 6 octobre 2003 Statut Membre Dernière intervention 31 octobre 2019 1
1 sept. 2004 à 11:51
Bonjour,

Met ca, c plu facile :

'SUPPRIMER UNE VALEUR OU UNE CLE DU REGISTRE

Set WshShell = CreateObject("Wscript.Shell")
WshShell.RegDelete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\Clef"


@ Plus ;)

BIL@Loch
:)
3
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
1 sept. 2004 à 12:02
bilaloch, machine script a proscrire pour acces base de registres, le prog se fera stopper a l'execution sur un systeme correctement configure.
Employer API dans tous les cas.

ciao...
BruNews, Admin CS, MVP VC++
0
bilaloch Messages postés 556 Date d'inscription lundi 6 octobre 2003 Statut Membre Dernière intervention 31 octobre 2019 1
1 sept. 2004 à 12:15
Bonjour,

Ok merci

Merci :approve) et @ Plus ;)

BIL@Loch
:)
0
Rejoignez-nous