Tema: helppp
Ver Mensaje Individual
  #5 (permalink)  
Antiguo 26/01/2009, 06:48
kakoxvid
 
Fecha de Ingreso: enero-2009
Mensajes: 31
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: helppp

Cita:
Iniciado por Avellaneda Ver Mensaje
Código:
' en la parte de declaraciones del módulo:
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult 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 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

Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1

' en el Load del Form o un CommandButton:
Dim lRet As Long, sSep As String
' leer el registro para comprobar el separador
RegOpenKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Jet\4.0\Engines\Text", lRet
sSep = LeerRegistro(lRet, "Format")
RegCloseKey lRet
If sSep <> "TabDelimited" Then
    ModificarRegistro HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Jet\4.0\Engines\Text", "Format", "TabDelimited"
End If

' Funciones para leer y modificar el registro:
Function LeerRegistro(ByVal HK_LM As Long, ByVal sValor As String) As String
Dim lRet As Long, lLen As Long, sBuffer As String
lRet = RegQueryValueEx(HK_LM, sValor, 0, 0, ByVal 0, lLen)
If lRet = 0 Then
    sBuffer = String(lLen, Chr$(0))
    lRet = RegQueryValueEx(HK_LM, sValor, 0, 0, ByVal sBuffer, lLen)
    If lRet = 0 Then
        LeerRegistro = Left$(sBuffer, InStr(1, sBuffer, Chr$(0)) - 1)
    End If
End If
End Function
'

Sub ModificarRegistro(HKLM As Long, sPath As String, sClave As String, sDatos As String)
Dim lRet As Long, hKey As Long
lRet = RegCreateKey(HKLM, sPath, hKey)
lRet = RegSetValueEx(hKey, sClave, 0, REG_SZ, ByVal sDatos, Len(sDatos))
lRet = RegCloseKey(hKey)
End Sub
Saludos

gracias amigo por la ayuda ,, pero sabes me manda un error que dice procedimiento sub o function no definido
y me marca la linea del RegOpenKey