• Sábado 20 de Abril de 2024, 11:08

Autor Tema:  Obtener Valor Binario Del Registro  (Leído 2155 veces)

MindEye

  • Miembro MUY activo
  • ***
  • Mensajes: 185
    • Ver Perfil
Obtener Valor Binario Del Registro
« en: Viernes 18 de Febrero de 2005, 16:59 »
0
- Hola compys, como puedo leer un valor binario del registro, como por ejemplo
'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Controls Folder\Presentation Cache' que es de tipo Reg_Binary. Es que cuando lo intento, me cierra todo el programa, hasta el visual basic me lo cierra, es que no se que hacer. He probado con variables de tipo variant, y incluso a no declararla, pero nada.

 - Ayuda please.

 - Gracias compys.

Cyclop

  • Miembro MUY activo
  • ***
  • Mensajes: 323
    • Ver Perfil
    • http://www.geocities.com/icotext/spanish/
Re: Obtener Valor Binario Del Registro
« Respuesta #1 en: Viernes 18 de Febrero de 2005, 17:04 »
0
Usa el WScript es mas facil

Salu2

Cyclopz
Icotext Evolution v0.5 para los amantes del ASCII Art
http]

MindEye

  • Miembro MUY activo
  • ***
  • Mensajes: 185
    • Ver Perfil
Re: Obtener Valor Binario Del Registro
« Respuesta #2 en: Viernes 18 de Febrero de 2005, 18:11 »
0
- Vale, pero como, es que no lo entiendo, es posible que me des un pequeño ejemplo, para aclararme


 - Gracias

Cyclop

  • Miembro MUY activo
  • ***
  • Mensajes: 323
    • Ver Perfil
    • http://www.geocities.com/icotext/spanish/
Re: Obtener Valor Binario Del Registro
« Respuesta #3 en: Sábado 19 de Febrero de 2005, 02:41 »
0
Prueba esto, no se si funcionara pero lo hice en una maquina que no tiene VB

Código: Text
  1.  
  2. Dim WSHShell
  3. Set WSHShell = WScript.CreateObject("WScript.Shell")
  4.  
  5. bin = ReadKey("HKCU\MiCarpeta\MiRegistroBinario")
  6. For n = 0 To UBound(bin)
  7.      Me.Print Chr(bin(n))
  8. Next
  9.  
  10. Function ReadKey(ByVal sPath As String) As String
  11.             ReadKey = WSHShell.RegRead(sPath)
  12. End Function
  13.  
  14. Sub CreateKey(ByVal sPath As String, ByVal sValue As String)
  15.        WSHShell.RegWrite sPath, sValue
  16. End Sub
  17.  
  18. Sub DeleteKey(ByVal sPath As String)
  19.       WSHShell.RegDelete sPath
  20. End Sub
  21.  
  22.  

Suerte

Cyclopz
Icotext Evolution v0.5 para los amantes del ASCII Art
http]

Brroz

  • Miembro de PLATA
  • *****
  • Mensajes: 1058
    • Ver Perfil
Re: Obtener Valor Binario Del Registro
« Respuesta #4 en: Sábado 19 de Febrero de 2005, 10:15 »
0
Hola

Ahí va:
Código: Text
  1.  
  2. Option Explicit
  3.  
  4. Private Const HKEY_LOCAL_MACHINE = &H80000002
  5. Private Const ERROR_SUCCESS = 0&
  6. Private Const KEY_QUERY_VALUE = &H1
  7. Private Const REG_BINARY = 3
  8.  
  9. Private 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
  10. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
  11. Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Byte, lpcbData As Long) As Long
  12.  
  13. Private Sub Command1_Click()
  14.    
  15.     Dim lRc As Long
  16.     Dim lhKey1 As Long, lhKey2 As Long
  17.    
  18.     lRc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software", 0&, KEY_QUERY_VALUE, lhKey1)
  19.     If lRc <> ERROR_SUCCESS Then Exit Sub
  20.    
  21.     lRc = RegOpenKeyEx(lhKey1, "Microsoft", 0&, KEY_QUERY_VALUE, lhKey2)
  22.     RegCloseKey lhKey1
  23.     If lRc <> ERROR_SUCCESS Then Exit Sub
  24.    
  25.     lRc = RegOpenKeyEx(lhKey2, "Windows", 0&, KEY_QUERY_VALUE, lhKey1)
  26.     RegCloseKey lhKey2
  27.     If lRc <> ERROR_SUCCESS Then Exit Sub
  28.    
  29.     lRc = RegOpenKeyEx(lhKey1, "CurrentVersion", 0&, KEY_QUERY_VALUE, lhKey2)
  30.     RegCloseKey lhKey1
  31.     If lRc <> ERROR_SUCCESS Then Exit Sub
  32.    
  33.     lRc = RegOpenKeyEx(lhKey2, "Controls Folder", 0&, KEY_QUERY_VALUE, lhKey1)
  34.     RegCloseKey lhKey2
  35.     If lRc <> ERROR_SUCCESS Then Exit Sub
  36.  
  37.     Dim bytData(4096) As Byte, lLen As Long
  38.     lRc = RegEnumValue(lhKey1, 1&, "Presentation Cache", 19&, 0&, REG_BINARY, bytData(0), 4096)
  39.     RegCloseKey lhKey1
  40.    
  41.     If lRc = ERROR_SUCCESS Then
  42.         Dim sChr As String, i1 As Integer
  43.         For i1 = 0 To 4095
  44.             sChr = sChr & Chr(bytData(i1))
  45.         Next i1
  46.         Debug.Print sChr
  47.     End If
  48.  
  49. End Sub
  50.  
  51.  

Se puede mejorar redimensionando bytData a la longitud exacta del valor y recuperando el índice del valor, pero como sé que así en mi caso vale...  imagino que en el tuyo también...

Chao.