Código:
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const ERROR_SUCCESS = 0&
Private Const REG_BINARY = 3
Private Const REG_DWORD = 4
Private Const REG_SZ = 1
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 ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Private Sub Form_Load()
If RegSetValueEx(HKEY_LOCAL_MACHINE, "hola", 0&, REG_SZ, "Esto es una prueba", Len("Esto es una prueba") + 1 ) = ERROR_SUCCESS Then
MsgBox "soy un genio"
Else
MsgBox "ups"
End If
Unload Me
End Sub
Pero el valor del registro en vez de contener "Esto es uan prueba", me aparece con simbolos raros (como si hubiese ocurrido algun error: d±).
Probe cambiando el string en Len(x) por una variable pero tampoco. Y probe sacandole el mas 1 y tampoco.
Tampoco me sale con binario ni con numeros. Que estoy haciendo mal?