La Web del Programador: Comunidad de Programadores
 
    Pregunta:  9100 - EDICIóN DE REGEDIT
Autor:  Alejandro Eduardo Henríquez Ardiles
Hola a todo el mundo
quisiera hacereles una pregunta.
Como puedo acceder y modificar el regedit desde visual basic 6, es decir crear una nueva clave, editar la información, etc.

Desde ya muchas gracias y un afectuoso saludo a todos.
chao, que esten bien.

  Respuesta:  José Ariel Limandri
Lo que queres hacer es modificar el registro (no el regedit). Para ello basete en el sigte codigo:

'Crear un formulario con 3 commandbutton
'usar HKCU for HKEY_CURRENT_USER
'usar HKLM for HKEY_LOCAL_MACHINE
'usar HKCR for HKEY_CLASSES_ROOT & HKEY_USERS & HKEY_CURRENT_CONFIG

Private Sub Form_Load()
Command1.Caption = "Escribir"
Command2.Caption = "Leer"
Command3.Caption = "Borrar"
End Sub

Private Sub Command1_Click()
Dim b As Object
On Error Resume Next
Set b = CreateObject("wscript.shell")
b.RegWrite "HKCU\VBCODE.COM\Value", "Hola Mundo"
b.RegWrite "HKCU\VBCODE.COM\Value1", 0, "REG_DWORD"
b.RegWrite "HKCU\VBCODE.COM\Value2", 0, "REG_SZ"
b.RegWrite "HKCU\VBCODE.COM\Value3", 0, "REG_BINARY"
End Sub

Private Sub Command2_Click()
Dim b As Object
On Error Resume Next
Set b = CreateObject("wscript.shell")
R = b.RegRead("HKCU\VBCODE.COM\Value")
Form1.Caption = R
End Sub

Private Sub Command3_Click()
Dim b As Object
On Error Resume Next

Set b = CreateObject("Wscript.Shell")
b.RegDelete "HKCU\VBCODE.COM\Value"
b.RegDelete "HKCU\VBCODE.COM\Value1"
b.RegDelete "HKCU\VBCODE.COM\Value2"
b.RegDelete "HKCU\VBCODE.COM\Value3"
End Sub