elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Security Series.XSS. [Cross Site Scripting]


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  que API necesito para comprobar si exciste..
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: que API necesito para comprobar si exciste..  (Leído 2,076 veces)
ricardovinzo

Desconectado Desconectado

Mensajes: 135


P.T.C


Ver Perfil
que API necesito para comprobar si exciste..
« en: 9 Agosto 2008, 03:06 am »

bueno gente queria saber que necesito (API o le que sea) para comprobar si una cadena en el registro (Como en el registro parte del registro Run) exciste!?

Gracias!


En línea

3# Convocacion de Moderadores en Code Makers, entra!
seba123neo
Moderador
***
Desconectado Desconectado

Mensajes: 3.621



Ver Perfil WWW
Re: que API necesito para comprobar si exciste..
« Respuesta #1 en: 9 Agosto 2008, 03:11 am »

es tan facil que ni lo explico...bajate el api-guide ahi esta... o sino tenes una clase llamada clsLightning y esta tiene todo...


En línea

ricardovinzo

Desconectado Desconectado

Mensajes: 135


P.T.C


Ver Perfil
Re: que API necesito para comprobar si exciste..
« Respuesta #2 en: 9 Agosto 2008, 03:42 am »

man solo porfavor.. decime el nombre de la API.. se que estan las apis Reg para manipular al registro pero son como 9 o 10 que tengo que estudiarlas bien.. y por los moemntos estoy escado de tiempo...

A ver si me dan mas ayuda pleas!
En línea

3# Convocacion de Moderadores en Code Makers, entra!
BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: que API necesito para comprobar si exciste..
« Respuesta #3 en: 9 Agosto 2008, 04:12 am »

bueno gente queria saber que necesito (API o le que sea) para comprobar si una cadena en el registro (Como en el registro parte del registro Run) exciste!?

Gracias!

mmm si mas no recuerdo es retornar un valor pero si no me devuelve nada o me da un error es que no existe.

PAra verificar que exteste llama a QueryValue

Espero te sirva...

En Un Modulo Clase:
Código
  1. Option Explicit
  2.  
  3. Const REG_SZ As Long = 1
  4. Const REG_DWORD As Long = 4
  5.  
  6. 'Const HKEY_CLASSES_ROOT = &H80000000
  7. 'Const HKEY_CURRENT_USER = &H80000001
  8. 'Const HKEY_LOCAL_MACHINE = &H80000002
  9. 'Const HKEY_USERS = &H80000003
  10.  
  11. Const ERROR_NONE = 0
  12. Const ERROR_BADDB = 1
  13. Const ERROR_BADKEY = 2
  14. Const ERROR_CANTOPEN = 3
  15. Const ERROR_CANTREAD = 4
  16. Const ERROR_CANTWRITE = 5
  17. Const ERROR_OUTOFMEMORY = 6
  18. Const ERROR_INVALID_PARAMETER = 7
  19. Const ERROR_ACCESS_DENIED = 8
  20. Const ERROR_INVALID_PARAMETERS = 87
  21. Const ERROR_NO_MORE_ITEMS = 259
  22.  
  23. Const KEY_ALL_ACCESS = &H3F
  24.  
  25. Const REG_OPTION_NON_VOLATILE = 0
  26.  
  27. Private Type FILETIME
  28.            dwLowDateTime As Long
  29.            dwHighDateTime As Long
  30. End Type
  31. 'Public Enum ClavePredefinida
  32. '    HKEY_CLASSES_ROOT = &H80000000
  33. '    HKEY_CURRENT_USER = &H80000001
  34. '    HKEY_LOCAL_MACHINE = &H80000002
  35. '    HKEY_USERS = &H80000003
  36. 'End Enum
  37.  
  38. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
  39. Private 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
  40. 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
  41. Private 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
  42. Private 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
  43. Private 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
  44. Private 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
  45. Private 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
  46. Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
  47. Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
  48. Private Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As FILETIME) As Long
  49. Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, lpReserved As Long, lpType As Long, lpData() As Byte, lpcbData As Long) As Long
  50. Private Declare Function RegQueryInfoKey Lib "advapi32.dll" Alias "RegQueryInfoKeyA" (ByVal hKey As Long, ByVal lpClass As String, lpcbClass As Long, lpReserved As Long, lpcSubKeys As Long, lpcbMaxSubKeyLen As Long, lpcbMaxClassLen As Long, lpcValues As Long, lpcbMaxValueNameLen As Long, lpcbMaxValueLen As Long, lpcbSecurityDescriptor As Long, lpftLastWriteTime As FILETIME) As Long
  51. Public Function DeleteKey(lPredefinedKey As Long, sKeyName As String) As Boolean
  52. ' Descripción:
  53. '   Esta función borra una clave y devuelve true si pudo borrarla o false si no pudo
  54. '
  55. ' Sintaxis:
  56. '   variable = DeleteKey (ClaveRaíz, NombreDeClave)
  57. '
  58. '   ClaveRaíz debe ser HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_lOCAL_MACHINE
  59. '   o HKEY_USERS
  60. '
  61. '   NombreDeClave es el nombre de la clave que queremos borrar,
  62. '   puede incluir subclaves (por ejemplo "Clave1\SubClave1")
  63. '
  64. ' Nota :
  65. '   En W95 borrará todas las subclaves de la clave eliminada, en NT no se puede borrar
  66. '   una clave que tenga subclaves
  67.  
  68.  
  69.    Dim lRetVal As Long      'resultado de la función SetValueEx
  70.    Dim hKey As Long         'handle de la clave abierta
  71.  
  72.    'para borrar una clave debe estar abierta
  73.    lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
  74.    'borramos la clave
  75.    lRetVal = RegDeleteKey(lPredefinedKey, sKeyName)
  76.    DeleteKey = IIf(lRetVal = 0, True, False)
  77. End Function
  78. Public Function DeleteValue(lPredefinedKey As Long, sKeyName As String, sValueName As String) As Boolean
  79. ' Descripción:
  80. '   Esta función borra un valor y devuelve true si pudo borrarlo y false si no pudo
  81. '
  82. ' Sintaxis:
  83. '   variable = DeleteValue (ClaveRaíz, NombreDeClave, NombreDeValor)
  84. '
  85. '   ClaveRaíz debe ser HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_lOCAL_MACHINE
  86. '   o HKEY_USERS
  87. '
  88. '   NombreDeClave es el nombre de la clave que contiene el valor que queremos borrar,
  89. '   puede incluir subclaves (por ejemplo "Clave1\SubClave1")
  90. '
  91. '   NombreDeValor es el nombre del valor que queremos borrar
  92.  
  93.       Dim lRetVal As Long      'resultado de la función SetValueEx
  94.       Dim hKey As Long         'handle de la clave abierta
  95.  
  96.       'abrimos la clave especificada
  97.       lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
  98.       'borramos el valor
  99.       lRetVal = RegDeleteValue(hKey, sValueName)
  100.       DeleteValue = IIf(lRetVal = 0, True, False)
  101.       'la cerramos
  102.       RegCloseKey (hKey)
  103. End Function
  104.  
  105. Public Function EnumKey(lPredefinedKey As Long, sKeyName As String, vSubKeys As Variant) As Long
  106. ' Descripción:
  107. '   Esta función busca todas las subclaves de una dada y forma una matriz con ellas en
  108. '   el parámetro vSubKeys.
  109. '
  110. '   Si queremos saber las subclaves de una de las principales debemos dejar en blanco
  111. '   el parámetro sKeyName
  112. '
  113. '   Devuelve el número de subclaves o -1 si hubo algún error
  114. '
  115. ' Sintaxis:
  116. '   variable = EnumKey (ClaveRaíz, NombreDeClave,SubClaves)
  117. '
  118. '   ClaveRaíz debe ser HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_lOCAL_MACHINE
  119. '   o HKEY_USERS
  120. '
  121. '   NombreDeClave es el nombre de la clave cuyas subclaves queremos obtener,
  122. '   puede incluir subclaves (por ejemplo "Clave1\SubClave1")
  123. '
  124. '   SubClaves es un variant que recogerá la matriz de subclaves obtenida
  125.  
  126.    Dim lRetVal As Long             'resultado de las funciones del API
  127.    Dim hKey As Long                'handle de la clave abierta
  128.    Dim sSubKeyName As String       'nombre de la subclave
  129.    Dim lSubKeyLen As Long          'tamaño del nombre de la subclave
  130.    Dim lMaxSubKeyLen As Long       'tamaño del nombre de subclave más grande
  131.    Dim lNumSubKeys As Long         'número de subclaves existentes
  132.    Dim ftLastWriteTime As FILETIME 'fecha última modif. de la clave (sólo NT)
  133.    Dim lIndex As Long              'índice de la subclave
  134.    Dim sSubClaves() As String      'matriz para contener las subclaves
  135.  
  136.    EnumKey = -1
  137.    'si tenemos nombre de clave la abrimos
  138.    If sKeyName <> "" Then
  139.        lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
  140.    Else
  141.        hKey = lPredefinedKey
  142.    End If
  143.    'obtenemos el nº de subclaves y el tamaño máximo de sus nombres
  144.    lRetVal = RegQueryInfoKey(hKey, 0&, 0&, 0&, lNumSubKeys, lMaxSubKeyLen, 0&, 0&, 0&, 0&, 0&, ftLastWriteTime)
  145.    If lRetVal = 0 Then
  146.        'si no encontré subclaves
  147.        If lNumSubKeys = 0 Then
  148.            EnumKey = 0
  149.        Else
  150.            EnumKey = lNumSubKeys
  151.            lNumSubKeys = lNumSubKeys - 1       ' va de 0 a n-1
  152.            lMaxSubKeyLen = lMaxSubKeyLen + 1   ' dejar sitio para el 0 de fin de string en c
  153.            'dimensionamos la matriz
  154.            ReDim sSubClaves(lNumSubKeys)
  155.            'recorremos las subclaves (en orden inverso, como dice la ayuda ¿?)
  156.            For lIndex = lNumSubKeys To 0 Step -1
  157.                lSubKeyLen = lMaxSubKeyLen
  158.                sSubKeyName = String(lMaxSubKeyLen, 0)
  159.                lRetVal = RegEnumKeyEx(hKey, lIndex, sSubKeyName, lSubKeyLen, 0&, 0&, 0&, ftLastWriteTime)
  160.                If lRetVal = 0 Then
  161.                    sSubClaves(lIndex) = Left$(sSubKeyName, lSubKeyLen)
  162.                Else
  163.                    EnumKey = -1
  164.                End If
  165.            Next lIndex
  166.        End If
  167.    Else
  168.        EnumKey = -1
  169.    End If
  170.    'devolvemos el resultado
  171.    vSubKeys = sSubClaves()
  172.    'cerramos la clave
  173.    If sKeyName <> "" Then RegCloseKey (hKey)
  174. End Function
  175.  
  176. Public Function EnumValue(lPredefinedKey As Long, sKeyName As String, vValues As Variant) As Long
  177. ' Descripción:
  178. '   Esta función busca todos los valores de una clave y forma una matriz con ellos
  179. '   en el parámetro vValues.
  180. '
  181. '   Si queremos saber las subclaves de una de las principales debemos dejar en blanco
  182. '   el parámetro sKeyName
  183. '
  184. '   Devuelve el número de valores o -1 si hubo algún error
  185. '
  186. ' Sintaxis:
  187. '   variable = EnumValue (ClaveRaíz, NombreDeClave,Valores)
  188. '
  189. '   ClaveRaíz debe ser HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_lOCAL_MACHINE
  190. '   o HKEY_USERS
  191. '
  192. '   NombreDeClave es el nombre de la clave cuyos valores y datos queremos obtener,
  193. '   puede incluir subclaves (por ejemplo "Clave1\SubClave1")
  194. '
  195. '   Valores es un variant que recogerá la matriz de valores y datos obtenida
  196.  
  197.    Dim lRetVal As Long             'resultado de las funciones del API
  198.    Dim hKey As Long                'handle de la clave abierta
  199.    Dim sValueName As String        'nombre del valor
  200.    Dim lValueNameLen As Long       'tamaño del nombre del valor
  201.    Dim lMaxValueNameLen As Long    'tamaño del nombre de valor más grande
  202.    Dim lNumValues As Long          'número de valores existentes
  203.    Dim bValueData(500) As Byte     'byte para obtener el dato del valor, no funciona?
  204.    Dim lValueSize As Long          'longitud del array anterior
  205.    Dim ftLastWriteTime As FILETIME 'fecha última modif. del valor (sólo NT)
  206.    Dim lIndex As Long              'índice del valor
  207.    Dim vValores() As String        'matriz para contener los valores
  208.  
  209.    EnumValue = -1
  210.    'si tenemos nombre de clave la abrimos
  211.    If sKeyName <> "" Then
  212.        lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
  213.    Else
  214.        hKey = lPredefinedKey
  215.    End If
  216.  
  217.    'obtenemos el nº de valores y el tamaño máximo de sus nombres
  218.    lRetVal = RegQueryInfoKey(hKey, 0&, 0&, 0&, 0&, 0&, 0&, lNumValues, lMaxValueNameLen, 0&, 0&, ftLastWriteTime)
  219.    If lRetVal = 0 Then
  220.        'si no encontré valores
  221.        If lNumValues = 0 Then
  222.            EnumValue = 0
  223.        Else
  224.            EnumValue = lNumValues
  225.            lNumValues = lNumValues - 1 'va de 0 a n-1
  226.            lMaxValueNameLen = lMaxValueNameLen + 1 'para que quepa el 0 de fin de cadena en C
  227.            'dimensionamos la matriz
  228.            ReDim vValores(lNumValues)
  229.            'recorremos los valores (en orden inverso, como dice la ayuda ¿?)
  230.            For lIndex = lNumValues To 0 Step -1
  231.                lValueNameLen = lMaxValueNameLen
  232.                sValueName = String(lMaxValueNameLen, 0)
  233.                lValueSize = 500
  234.                'no me funciona si no pongo un array de bytes para recoger el resultado,
  235.                'aunque luego no me lo da¿?. Si pones una longitud menor de lo que ocupa
  236.                'el dato tampoco funciona, por eso puse 500 bytes
  237.                lRetVal = RegEnumValue(hKey, lIndex, sValueName, lValueNameLen, 0&, 0&, bValueData(), lValueSize)
  238.                If lRetVal = 0 Then
  239.                    vValores(lIndex) = Left$(sValueName, lValueNameLen)
  240.                Else
  241.                    EnumValue = -1
  242.                End If
  243.            Next lIndex
  244.        End If
  245.    Else
  246.        EnumValue = -1
  247.    End If
  248.    'devolvemos el resultado
  249.    vValues = vValores()
  250.    'cerramos la clave
  251.    If sKeyName <> "" Then RegCloseKey (hKey)
  252.  
  253. End Function
  254. Private Function SetValueEx(ByVal hKey As Long, sValueName As String, ltype As Long, vValue As Variant) As Long
  255. '
  256. ' Función utilizada por SetValue, no debemos llamarla directamente
  257. '
  258.    Dim lValue As Long
  259.    Dim sValue As String
  260.  
  261.    Select Case ltype
  262.        Case REG_SZ
  263.            sValue = vValue
  264.            SetValueEx = RegSetValueExString(hKey, sValueName, 0&, ltype, sValue, Len(sValue))
  265.        Case REG_DWORD
  266.            lValue = vValue
  267.            SetValueEx = RegSetValueExLong(hKey, sValueName, 0&, ltype, lValue, 4)
  268.    End Select
  269.  
  270. End Function
  271. Private Function QueryValueEx(ByVal lhKey As Long, ByVal szValueName As String, vValue As Variant) As Long
  272. '
  273. ' Función utilizada por QueryValue, no debemos llamarla directamente
  274. '
  275.    Dim cch As Long
  276.    Dim lrc As Long
  277.    Dim ltype As Long
  278.    Dim lValue As Long
  279.    Dim sValue As String
  280.  
  281.    On Error GoTo QueryValueExError
  282.  
  283.  
  284.    ' Determinar el tipo de datos y el tamaño que debemos leer
  285.  
  286.    lrc = RegQueryValueExNULL(lhKey, szValueName, 0&, ltype, 0&, cch)
  287.    If lrc <> ERROR_NONE Then Error 5
  288.  
  289.    Select Case ltype
  290.        ' Para strings
  291.        Case REG_SZ:
  292.            sValue = String(cch, 0)
  293.            lrc = RegQueryValueExString(lhKey, szValueName, 0&, ltype, sValue, cch)
  294.            If lrc = ERROR_NONE Then
  295.                vValue = Left$(sValue, cch - 1)
  296.            Else
  297.                vValue = Empty
  298.            End If
  299.  
  300.        ' Para DWORDS (long)
  301.        Case REG_DWORD:
  302.            lrc = RegQueryValueExLong(lhKey, szValueName, 0&, ltype, lValue, cch)
  303.            If lrc = ERROR_NONE Then vValue = lValue
  304.        Case Else
  305.            'no están soportados otros tipos
  306.            lrc = -1
  307.    End Select
  308.  
  309. QueryValueExExit:
  310.  
  311.    QueryValueEx = lrc
  312.    Exit Function
  313.  
  314. QueryValueExError:
  315.  
  316.    Resume QueryValueExExit
  317.  
  318. End Function
  319. Public Function SetValue(lPredefinedKey As Long, sKeyName As String, sValueName As String, vValueSetting As Variant, lValueType As Long) As Boolean
  320. ' Descripción:
  321. '   Esta función crea y/o modifica el dato contenido en un valor y devuelve true si lo
  322. '   modificó o false si no pudo
  323. '   Si no existen la clave y/o subclaves las crea
  324. '
  325. ' Sintaxis:
  326. '   variable = SetValue (ClaveRaíz, NombreDeClave, NombreDeValor, NuevoDato, TipoDeDato)
  327. '
  328. '   ClaveRaíz debe ser HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_lOCAL_MACHINE
  329. '   o HKEY_USERS
  330. '
  331. '   NombreDeClave es el nombre de la clave que contiene el valor que queremos recuperar,
  332. '   puede incluir subclaves (por ejemplo "Clave1\SubClave1")
  333. '
  334. '   NombreDeValor es el nombre del valor que queremos crear o modificar
  335.  
  336. '   NuevoDato es el dato que queremos introducir en el valor
  337. '
  338. '   TipoDeDato debe ser REG_SZ (un string) o REG_DWORD (un long)
  339.  
  340.        Dim lRetVal As Long      'resultado de la función SetValueEx
  341.        Dim hKey As Long         'handle de la clave abierta
  342.  
  343.        'abrimos la clave
  344.        lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
  345.        'si no pudimos abrirla la creamos
  346.        If lRetVal <> 0 Then
  347.             lRetVal = CreateNewKey(lPredefinedKey, sKeyName)
  348.             lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
  349.         End If
  350.        'modificamos el dato del valor
  351.        lRetVal = SetValueEx(hKey, sValueName, lValueType, vValueSetting)
  352.        SetValue = IIf(lRetVal = 0, True, False)
  353.        'cerramos la clave
  354.        RegCloseKey (hKey)
  355.  
  356. End Function
  357. Public Function QueryValue(lPredefinedKey As Long, sKeyName As String, sValueName As String, Optional vDefault)
  358. ' Descripción:
  359. '   Esta función devuelve los datos de un valor o Empty si no lo encontró
  360. '   Si no existe el valor devuelve el de por defecto
  361. '
  362. ' Sintaxis:
  363. '   variable = QueryValue(ClaveRaíz, NombreDeClave, NombreDeValor)
  364. '
  365. '   ClaveRaíz debe ser HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_lOCAL_MACHINE
  366. '   o HKEY_USERS
  367. '
  368. '   NombreDeClave es el nombre de la clave que contiene el valor que queremos recuperar,
  369. '   puede incluir subclaves (por ejemplo "Clave1\SubClave1")
  370. '
  371. '   NombreDeValor es el nombre del valor que queremos recuperar, si es null devolverá
  372. '   el valor predeterminado de la clave (si existe)
  373.  
  374.    Dim lRetVal As Long      'resultado de las funciones del API
  375.    Dim hKey As Long         'handle de la clave abierta
  376.    Dim vValue As Variant    'datos del valor requerido
  377.  
  378.    'abrimos la clave
  379.    lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
  380.    'obtenemos los datos del valor
  381.    lRetVal = QueryValueEx(hKey, sValueName, vValue)
  382.    If Not IsMissing(vDefault) And IsEmpty(vValue) Then
  383.        QueryValue = vDefault
  384.    Else
  385.        QueryValue = vValue
  386.    End If
  387.    'cerramos la clave
  388.    RegCloseKey (hKey)
  389. End Function
  390. Public Function CreateNewKey(lPredefinedKey As Long, sNewKeyName As String) As Boolean
  391. ' Descripción:
  392. '   Esta función crea una nueva clave y devuelve true si pudo crearla o false si no pudo
  393. '
  394. ' Sintaxis:
  395. '   variable = CreateNewKey (ClaveRaíz, NombreDeClave)
  396. '
  397. '   ClaveRaíz debe ser igual a HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_lOCAL_MACHINE
  398. '   o HKEY_USERS
  399. '
  400. '   NombreDeClave es el nombre de la clave que queremos crear,
  401. '   puede incluir subclaves (por ejemplo "Clave1\SubClave1")
  402.  
  403.    Dim hNewKey As Long         'handle a la nueva clave
  404.    Dim lRetVal As Long         'resultado de la función RegCreateKeyEx
  405.  
  406.    lRetVal = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey, lRetVal)
  407.    CreateNewKey = IIf(lRetVal = 0, True, False)
  408.    'cerramos la clave
  409.    RegCloseKey (hNewKey)
  410. End Function
  411. Public Property Get HKEY_USERS() As Long
  412.    HKEY_USERS = &H80000003
  413. End Property
  414. Public Property Get HKEY_LOCAL_MACHINE() As Long
  415.    HKEY_LOCAL_MACHINE = &H80000002
  416. End Property
  417. Public Property Get HKEY_CURRENT_USER() As Long
  418.    HKEY_CURRENT_USER = &H80000001
  419. End Property
  420. Public Property Get TIPO_STRING() As Long
  421.    TIPO_STRING = REG_SZ
  422. End Property
  423. Public Property Get TIPO_LONG() As Long
  424.    TIPO_LONG = REG_DWORD
  425. End Property
  426. Public Property Get HKEY_CLASSES_ROOT() As Long
  427.    HKEY_CLASSES_ROOT = &H80000000
  428. End Property
  429.  
« Última modificación: 9 Agosto 2008, 04:36 am por ░▒▓BlackZeroҖ▓▒░ » En línea

The Dark Shadow is my passion.
Spider-Net


Desconectado Desconectado

Mensajes: 1.165


Un gran poder conlleva una gran responsabilidad


Ver Perfil WWW
Re: que API necesito para comprobar si exciste..
« Respuesta #4 en: 9 Agosto 2008, 21:15 pm »

Código
  1. Set Objeto = CreateObject("wscript.shell")
  2. LeerReg = Objeto.RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\loquesea")
  3. If LeerReg = "" Then 'Si la rama está vacía quiere decir que no tiene ningún valor
  4.    'Aquí ya se supone que la rama está vacía o que no contiene ningún valor
  5. End If
  6.  

Así compruebo yo siempre si existe una rama concreta en el registro y sino existe, la vuelvo a crear ;)

Saludos!
En línea

seba123neo
Moderador
***
Desconectado Desconectado

Mensajes: 3.621



Ver Perfil WWW
Re: que API necesito para comprobar si exciste..
« Respuesta #5 en: 10 Agosto 2008, 01:13 am »

pues se hace con la api para abrir...RegOpenKeyEx...si retorna 0 no existe...
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
¿Que hacer para comprobar lo aprendido? « 1 2 »
Dudas Generales
piluve 15 7,195 Último mensaje 3 Enero 2011, 12:49 pm
por Garfield07
vbscript para comprobar conexiones
Scripting
nosoqui 0 4,314 Último mensaje 17 Marzo 2011, 15:06 pm
por nosoqui
Tutorial para comprobar la serguridad de una red
Seguridad
malospelosmalon 8 4,003 Último mensaje 2 Agosto 2011, 08:46 am
por malospelosmalon
Dudas en los resultados del testeo de un HDD para comprobar su estado.
Hardware
HdM 4 3,718 Último mensaje 18 Abril 2012, 19:13 pm
por HdM
Pagina para comprobar contraseñas
Redes
dato000 4 2,871 Último mensaje 31 Octubre 2012, 19:31 pm
por dato000
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines