1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| Function WriteKey(HKEY As String, PathKey As String, KeyVal As String, TypeOfKey As String) As Boolean
Dim GetKey As Variant
Set WshShell = CreateObject("WScript.Shell")
'Ecriture de la cl?
Select Case HKEY
Case "HKLM"
If Not IsAdmin Then
MsgBox "Acc?s au registre refus?, niveau de privil?ge insuffisant.", vbOKOnly + vbCritical, "Registre"
Exit Function
Else
WshShell.RegWrite HKEY & "\" & PathKey, KeyVal, TypeOfKey
End If
Case "HKCU"
WshShell.RegWrite HKEY & "\" & PathKey, KeyVal, TypeOfKey
Case "HKU"
WshShell.RegWrite HKEY & "\" & PathKey, KeyVal, TypeOfKey
Case "HKCC"
WshShell.RegWrite HKEY & "\" & PathKey, KeyVal, TypeOfKey
Case Else
MsgBox "Le type de registre demand? n'existe pas.", vbOKOnly + vbCritical, "Registre"
WriteKey = False
End Select
'Lecture de la cl?
GetKey = WshShell.RegRead(HKEY & "\" & PathKey)
If GetKey = KeyVal Then
WriteKey = True
Else
WriteKey = False
End If
End Function |
Partager