acceso al registro de windows

Jon
19 de Noviembre del 2003
Buenas:
Necesito acceder al registro de windows para recuperar el valor de unas variables.. como se accede a dicho registr ? muchas gracias

sdemingo
19 de Noviembre del 2003
Hola,

tendrás que hacerlo co nla API.
Declara esto en un módulo:
'##############################################################################################
'####### DECLARACIONES PARA LA LECTURA DE REGISTRO POR API


' Declaración de funciones del API de Windows

Public Const REG_SZ As Long = 1
Public Const REG_DWORD As Long = 4

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

Public Const ERROR_NONE = 0
Public Const ERROR_BADDB = 1
Public Const ERROR_BADKEY = 2
Public Const ERROR_CANTOPEN = 3
Public Const ERROR_CANTREAD = 4
Public Const ERROR_CANTWRITE = 5
Public Const ERROR_OUTOFMEMORY = 6
Public Const ERROR_ARENA_TRASHED = 7
Public Const ERROR_ACCESS_DENIED = 8
Public Const ERROR_INVALID_PARAMETERS = 87
Public Const ERROR_NO_MORE_ITEMS = 259

Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_ALL_ACCESS = &H3F

Public Const REG_OPTION_NON_VOLATILE = 0



Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition 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 RegQueryValueExString 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 RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Long, lpcbData As Long) As Long
Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Long, lpcbData As Long) As Long
Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long


Y Luego accedes así:

Para grabar nuevas entradas:
SaveSetting "sigcat2002", "sigcatHDP", "PathDirectorioTrabajo", strPath
SaveSetting "sigcat2002", "sigcatHDP", "BDPATH", cBBDD
SaveSetting "sigcat2002", "sigcatHDP", "UsosPATH", cUsosyDestinos SaveSetting "sigcat2002", "sigcatHDP", "MemoriaPATH", cMemoria
SaveSetting "sigcat2002", "sigcatHDP", "TextoArticuladoPATH", cTArticulado SaveSetting "sigcat2002", "sigcatHDP", "PathDocumentoCatalogo", cDCatalogo
SaveSetting "sigcat2002", "sigcatHDP", "PathDocumentoCatalogoCopia", cDCatalogoAuxiliar

Para Borrar Entradas:
DeleteSetting "sigcat2002", "sigcatHDP", "PathDirectorioTrabajo"
DeleteSetting "sigcat2002", "sigcatHDP", "BDPATH"
DeleteSetting "sigcat2002", "sigcatHDP", "TextoArticuladoPATH"
DeleteSetting "sigcat2002", "sigcatHDP", "UsosPATH"
DeleteSetting "sigcat2002", "sigcatHDP", "MemoriaPATH"
DeleteSetting "sigcat2002", "sigcatHDP", "PathDocumentoCatalogo"
DeleteSetting "sigcat2002", "sigcatHDP", "PathDocumentoCatalogoCopia"

Para acceder a por un valor:
ruta = GetSetting("sigcat2002", "sigcatHDP", "PathDirectorioTrabajo", "")


Un saludo
sdemingo

Jos?
19 de Noviembre del 2003
Existe un codigo de ejemplo que se llama regsettings en www.portalVb.com, este ejemplo permite grabar, recuperar, eliminar registros de windows. si no consigues el ejemplo enviame un mail

José