supprimer registre

Le
wess3310
Bonjour,
j'ai besoin d'un code source en VB6 qui me permet de supprimer le registre suivant :

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionHotFIX

merci
Vidéos High-Tech et Jeu Vidéo
Téléchargements
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
bahn po
Le #16724511
wess3310 a couché sur son écran :
Bonjour,
j'ai besoin d'un code source en VB6 qui me permet de supprimer le registre
suivant :

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionHotFIX

merci



Je te fais un copier/coller d'un code trouvé il y a qq temps, l'auteur
se reconnaîtra peut être. Avec ça tu peux créer ou supprimer une clef,
ou la lire dans la bdr. Très simple à utiliser.

A coller dans un module:


Public Enum HKEYs
HKEY_CLASSES_ROOT = 0
HKEY_CURRENT_USER = 1
HKEY_LOCAL_MACHINE = 2
HKEY_USERS = 3
HKEY_CURRENT_CONFIG = 4
End Enum

Public Enum REG_TYPE
REG_String = 0
REG_Number = 1
REG_Binary = 2
REG_Expand_String = 3
End Enum

Public Sub REcrit(HKEY As HKEYs, Endroit As String, Valeur As String,
Optional Type_Of_Reg As REG_TYPE = REG_String)
Dim WSHShell
Set WSHShell = CreateObject("WScript.Shell")
Select Case Type_Of_Reg
Case 0: WSHShell.RegWrite HK(HKEY) & Endroit, Valeur, "REG_SZ"
Case 1: WSHShell.RegWrite HK(HKEY) & Endroit, Valeur,
"REG_DWORD"
Case 2: WSHShell.RegWrite HK(HKEY) & Endroit, Valeur,
"REG_BINARY"
Case 3: WSHShell.RegWrite HK(HKEY) & Endroit, Valeur,
"REG_EXPAND_SZ"
End Select
End Sub

Public Function Lit(HKEY As HKEYs, Endroit As String, Optional
Retourner_En_Erreur As String = "zero") As String
On Error Resume Next
Dim WSHShell
Set WSHShell = CreateObject("WScript.Shell")
Lit = WSHShell.RegRead(HK(HKEY) & Endroit)
Retourner_En_Erreur = Lit

If Err <> 0 Then Lit = Retourner_En_Erreur
End Function

Public Sub Suprime(HKEY As HKEYs, Endroit As String)
On Error Resume Next
Dim WSHShell
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.RegDelete HK(HKEY) & Endroit
End Sub

Private Function HK(HKEY As HKEYs) As String
Select Case HKEY
Case 0: HK = "HKCR"
Case 1: HK = "HKCU"
Case 2: HK = "HKLM"
Case 3: HK = "HKEY_USERS"
Case 4: HK = "HKEY_CURRENT_CONFIG"
End Select
End Function




==============================
Ensuite, voici un exemple pour supprimer une clef :


Suprime HKEY_CURRENT_USER,
"SOFTWAREMicrosoftWindowsCurrentVersionRuntest"


Pour toi ça devrait donner

Suprime HKEY_LOCAL_MACHINE, "SOFTWAREMicrosoftWindows
NTCurrentVersionHotFIX"


ps: la faute d'ortographe à "suprime" est d'origine, je laisse,
question de copyright ;)
wess3310
Le #16726171
bahn po a écrit le 05/09/2008 à 12h06 :
wess3310 a couché sur son écran :
Bonjour,
j'ai besoin d'un code source en VB6 qui me permet de supprimer le registre
suivant :

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionHotFIX

merci




Je te fais un copier/coller d'un code trouvé il y a qq temps, l'auteur
se reconnaîtra peut être. Avec ça tu peux créer ou
supprimer une clef,
ou la lire dans la bdr. Très simple à utiliser.

A coller dans un module:


Public Enum HKEYs
HKEY_CLASSES_ROOT = 0
HKEY_CURRENT_USER = 1
HKEY_LOCAL_MACHINE = 2
HKEY_USERS = 3
HKEY_CURRENT_CONFIG = 4
End Enum

Public Enum REG_TYPE
REG_String = 0
REG_Number = 1
REG_Binary = 2
REG_Expand_String = 3
End Enum

Public Sub REcrit(HKEY As HKEYs, Endroit As String, Valeur As String,
Optional Type_Of_Reg As REG_TYPE = REG_String)
Dim WSHShell
Set WSHShell = CreateObject("WScript.Shell")
Select Case Type_Of_Reg
Case 0: WSHShell.RegWrite HK(HKEY) & Endroit, Valeur, "REG_SZ"
Case 1: WSHShell.RegWrite HK(HKEY) & Endroit, Valeur,
"REG_DWORD"
Case 2: WSHShell.RegWrite HK(HKEY) & Endroit, Valeur,
"REG_BINARY"
Case 3: WSHShell.RegWrite HK(HKEY) & Endroit, Valeur,
"REG_EXPAND_SZ"
End Select
End Sub

Public Function Lit(HKEY As HKEYs, Endroit As String, Optional
Retourner_En_Erreur As String = "zero") As String
On Error Resume Next
Dim WSHShell
Set WSHShell = CreateObject("WScript.Shell")
Lit = WSHShell.RegRead(HK(HKEY) & Endroit)
Retourner_En_Erreur = Lit

If Err <> 0 Then Lit = Retourner_En_Erreur
End Function

Public Sub Suprime(HKEY As HKEYs, Endroit As String)
On Error Resume Next
Dim WSHShell
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.RegDelete HK(HKEY) & Endroit
End Sub

Private Function HK(HKEY As HKEYs) As String
Select Case HKEY
Case 0: HK = "HKCR"
Case 1: HK = "HKCU"
Case 2: HK = "HKLM"
Case 3: HK = "HKEY_USERS"
Case 4: HK = "HKEY_CURRENT_CONFIG"
End Select
End Function




==============================
Ensuite, voici un exemple pour supprimer une clef :


Suprime HKEY_CURRENT_USER,
"SOFTWAREMicrosoftWindowsCurrentVersionRuntest"


Pour toi ça devrait donner

Suprime HKEY_LOCAL_MACHINE, "SOFTWAREMicrosoftWindows
NTCurrentVersionHotFIX"


ps: la faute d'ortographe à "suprime" est d'origine, je
laisse,
question de copyright ;)


merci pour le code
bon je suis debutant j'ai pas bien compris
j'ai declaré les registres dans mon module pour supprimer les url
je vais vous donner le code et la declaration et essaiez de m'aider avec une petite modification si c'est possible merci d'avance

voila le code de ma form
----------------------------------
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As Any, phkResult As Long, lpdwDisposition 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 SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long
Private Declare Function SHUpdateRecycleBinIcon Lib "shell32.dll" () As Long
Private Const RECYCLE_BIN = &HA&
Const REG_SZ = 1
Const HKEY_CURRENT_USER = &H80000001
Const REG_OPTION_NON_VOLATILE = 0
Const STANDARD_RIGHTS_ALL = &H1F0000
Const KEY_QUERY_VALUE = &H1
Const KEY_SET_VALUE = &H2
Const KEY_CREATE_SUB_KEY = &H4
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_CREATE_LINK = &H20
Const SYNCHRONIZE = &H100000
Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))

Dim hKey, ret As Long, tableofval(1 To 30) As String, z As Integer
Dim strRoot As String


----------------------------------------------------------------------------
voila le code demon module



Public Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ListeIdem) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Public Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As FILEDATE, lpLocalFileTime As FILEDATE) As Long
Public Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILEDATE, lpSystemTime As SYSTEMEDATE) As Long
Public Declare Function FindFirstUrlCacheEntry Lib "Wininet.dll" Alias "FindFirstUrlCacheEntryA" (ByVal lpszUrlSearchPattern As String, lpFirstCacheEntryInfo As Any, lpdwFirstCacheEntryInfoBufferSize As Long) As Long
Public Declare Function FindNextUrlCacheEntry Lib "Wininet.dll" Alias "FindNextUrlCacheEntryA" (ByVal hEnumHandle As Long, lpNextCacheEntryInfo As Any, lpdwNextCacheEntryInfoBufferSize As Long) As Long
Public Declare Function FindCloseUrlCache Lib "Wininet.dll" (ByVal hEnumHandle As Long) As Long
Public Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal dwLength As Long)
Public Declare Function lstrcpyA Lib "kernel32" (ByVal RetVal As String, ByVal Ptr As Long) As Long
Public Declare Function lstrlenA Lib "kernel32" (ByVal Ptr As Any) As Long
Public Declare Function LocalAlloc Lib "kernel32" (ByVal uFlags As Long, ByVal uBytes As Long) As Long
Public Declare Function LocalFree Lib "kernel32" (ByVal hMem As Long) As Long


'fonction qui retrouve toutes les entrées du cache internet URL COOKIES HISTORIQUE

Public Function GetURLCache(URLHistory() As InternetCacheEntree, Cookies() As InternetCacheEntree)
dwBuffer = 0
ReDim URLHistory(0)
ReDim Cookies(0)
hFile = FindFirstUrlCacheEntry(0&, ByVal 0, dwBuffer)
If (hFile = ERREURCACHE) And (Err.LastDllError = ERREURBUFFER) Then
PntrICE = LocalAlloc(ERREURFIXE, dwBuffer)
If PntrICE Then
CopyMemory ByVal PntrICE, dwBuffer, 4
hFile = FindFirstUrlCacheEntry(vbNullString, ByVal PntrICE, dwBuffer)
If hFile <> ERREURCACHE Then
Do
CopyMemory ICEI, ByVal PntrICE, Len(ICEI)
If (ICEI.CacheEntryType And NORMALENTREE) = NORMALENTREE Then
Select Case ICEI.CacheEntryType
Case HISTORIQUECACHE + NORMALENTREE
ReDim Preserve URLHistory(UBound(URLHistory) + 1)
URLHistory(UBound(URLHistory) - 1).SourceUrlName = GetStrFromPtrA(ICEI.lpszSourceUrlName)
URLHistory(UBound(URLHistory) - 1).LocalFileName = GetStrFromPtrA(ICEI.lpszLocalFileName)
URLHistory(UBound(URLHistory) - 1).FileExtension = GetStrFromPtrA(ICEI.lpszFileExtension)
URLHistory(UBound(URLHistory) - 1).HeaderInfo = GetStrFromPtrA(ICEI.lpHeaderInfo)
URLHistory(UBound(URLHistory) - 1).HitRate = ICEI.dwHitRate
URLHistory(UBound(URLHistory) - 1).ExpireTime = FileTime2SystemTime(ICEI.ExpireTime)
URLHistory(UBound(URLHistory) - 1).LastAccessTime = FileTime2SystemTime(ICEI.LastAccessTime)
URLHistory(UBound(URLHistory) - 1).LastModifiedTime = FileTime2SystemTime(ICEI.LastModifiedTime)
URLHistory(UBound(URLHistory) - 1).LastSyncTime = FileTime2SystemTime(ICEI.LastSyncTime)
URLHistory(UBound(URLHistory) - 1).Size = ICEI.dwSizeHigh * 2 ^ 32 + ICEI.dwSizeLow
URLHistory(UBound(URLHistory) - 1).UseCount = ICEI.dwUseCount
Case COOKIESCACHE + NORMALENTREE
ReDim Preserve Cookies(UBound(Cookies) + 1)
Cookies(UBound(Cookies) - 1).SourceUrlName = GetStrFromPtrA(ICEI.lpszSourceUrlName)
Cookies(UBound(Cookies) - 1).LocalFileName = GetStrFromPtrA(ICEI.lpszLocalFileName)
Cookies(UBound(Cookies) - 1).FileExtension = GetStrFromPtrA(ICEI.lpszFileExtension)
Cookies(UBound(Cookies) - 1).HeaderInfo = GetStrFromPtrA(ICEI.lpHeaderInfo)
Cookies(UBound(Cookies) - 1).HitRate = ICEI.dwHitRate
Cookies(UBound(Cookies) - 1).ExpireTime = FileTime2SystemTime(ICEI.ExpireTime)
Cookies(UBound(Cookies) - 1).LastAccessTime = FileTime2SystemTime(ICEI.LastAccessTime)
Cookies(UBound(Cookies) - 1).LastModifiedTime = FileTime2SystemTime(ICEI.LastModifiedTime)
Cookies(UBound(Cookies) - 1).LastSyncTime = FileTime2SystemTime(ICEI.LastSyncTime)
Cookies(UBound(Cookies) - 1).Size = ICEI.dwSizeHigh * 2 ^ 32 + ICEI.dwSizeLow
Cookies(UBound(Cookies) - 1).UseCount = ICEI.dwUseCount
End Select
DoEvents
End If
Call LocalFree(PntrICE)
dwBuffer = 0
Call FindNextUrlCacheEntry(hFile, ByVal 0, dwBuffer)
PntrICE = LocalAlloc(ERREURFIXE, dwBuffer)
CopyMemory ByVal PntrICE, dwBuffer, 4
Loop While FindNextUrlCacheEntry(hFile, ByVal PntrICE, dwBuffer)
End If
End If
End If
Call LocalFree(PntrICE)
Call FindCloseUrlCache(hFile)
End Function

------------------------
merci
bahn po
Le #16727661
Il se trouve que wess3310 a formulé :

merci pour le code
bon je suis debutant j'ai pas bien compris
j'ai declaré les registres dans mon module pour supprimer les url
je vais vous donner le code et la declaration et essaiez de m'aider avec une
petite modification si c'est possible merci d'avance



Touche pas à ton code. Tu ajoutes un module comme ceci
http://cjoint.com/data/jfrLEyGPCi.htm et il suffit d'y copier le code.

Ensuite dans ton programme, tu appelles la suppression d'une clef par

Suprime HKEY_LOCAL_MACHINE, "SOFTWAREMicrosoftWindows
NTCurrentVersionHotFIX"

Bye
Jean-marc
Le #16729871
wess3310 wrote:
bahn po a écrit le 05/09/2008 à 12h06 :
wess3310 a couché sur son écran :
Bonjour,
j'ai besoin d'un code source en VB6 qui me permet de supprimer le
registre suivant :

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionHotFIX







Pour être exhaustif, je mentionne en plus de la réponse précédente
les 2 articles suivant de la FAQ :
http://faq.vb.free.fr/index.php?questionY
http://faq.vb.free.fr/index.php?questiond

Cordialement,

--
Jean-marc Noury (jean_marc_n2)
Microsoft MVP - Visual Basic
FAQ VB: http://faq.vb.free.fr/
mailto: remove '_no_spam_' ;
Publicité
Poster une réponse
Anonyme