none
Alguien me puede decir como crear una clave en el registro de windows en vb 6 . RRS feed

  • Pregunta

  • En VB2005 en muy facil pero en VB6 como puedo decir que me cree una clave en el registro que sea del tipo:

     

    HKEY_CURRENT_USER\Control Panel\Desktop "Wallpaper" "C:\WINDOWS\Web\Wallpaper\Dunas.jpg"

     

    Esque puedo eliminarla pero no añadir una nueva.

    Como lo hago.

    Recordad es en VB6.

     

    Muchas gracias a los que respondan.

    saludos.

     

    viernes, 6 de julio de 2007 9:06

Respuestas

  • Un ejemplo:

     


    Code Snippet

    Public Const KEY_CREATE_LINK = &H20
    Public Const KEY_CREATE_SUB_KEY = &H4
    Public Const KEY_ENUMERATE_SUB_KEYS = &H8
    Public Const KEY_QUERY_VALUE = &H1
    Public Const KEY_NOTIFY = &H10
    Public Const KEY_SET_VALUE = &H2
    Public Const SYNCHRONIZE = &H100000
    Public Const STANDARD_RIGHTS_ALL = &H1F0000
    Public 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))


    Public Const HKEY_LOCAL_MACHINE = &H80000002
    Public Const HKEY_CURRENT_USER = &H80000001
    Public Const HKEY_USERS = &H80000003


    Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long
    Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long

    Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
    Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
    Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
    Declare Function RegFlushKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

    Function gPoneValorRegEx(rsHKEY As String, rsClave As String, rsValor As String, rsContenido As String) As String
    Dim mlLongo As Long
    Dim mlHKey As Long
    Dim msParametro As String
    Dim msDevuelve As String
    Dim hKey As Long

        If rsHKEY = "L" Then
           hKey = HKEY_LOCAL_MACHINE
        ElseIf rsHKEY = "U" Then
           hKey = HKEY_USERS
        Else
           hKey = HKEY_CURRENT_USER
        End If
        'Abrimos la Clave para Leer
        mlLongo = RegOpenKeyEx(hKey, rsClave, 0, KEY_ALL_ACCESS, mlHKey)
       
        If mlLongo = 0 Then    'Si se encontró *******************************************
            msParametro = rsContenido   'Asignamos valor
            'Escribimos el valor de la Clave
            mlLongo = RegSetValueEx(mlHKey, rsValor, 0, 1, msParametro, Len(msParametro))
            If mlLongo = 0 Then
               mlLongo = RegFlushKey(mlHKey)
            End If
            'Cerramos la Clave
            mlLongo = RegCloseKey(mlHKey)
        End If
    End Function

     

    Salu2

     

    Colabora con el foro: Si la respuesta te es de utilidad marca la pregunta como respondida.

    Luis Ruiz Pavón

    MCP - MCTS

    Blog: http://geeks.ms/blogs/lruiz

    viernes, 6 de julio de 2007 10:09