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

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Duda con proyecto de Leandro Ascierto
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Duda con proyecto de Leandro Ascierto  (Leído 2,410 veces)
illuminat3d

Desconectado Desconectado

Mensajes: 231



Ver Perfil WWW
Duda con proyecto de Leandro Ascierto
« en: 13 Marzo 2016, 20:16 pm »

Sobre este proyecto

Leandro no se donde utilizas los eventos del modulo de clase del Registro. No veo ninguna llamada a los EnumValues etc en el codigo solo veo esto

Código
  1.                Case 4
  2.                    RegistryID = WinSock32.WsConnect(ServerIP, ServerPuerto, True)
  3.  
  4.                    If RegistryID <> 0 Then
  5.  
  6.                        Dim cRemoteReg As ClsRemoteRegistry
  7.                        Set cRemoteReg = New ClsRemoteRegistry
  8.                        cRemoteReg.ID_Connection = RegistryID
  9.                        cColl.Add cRemoteReg, CStr(RegistryID)
  10.  
  11.                        WinSock32.SendData RegistryID, 6 & Delimiter & Cmd(1)
  12.  

Modulo del registro :

Código
  1. Option Explicit
  2. Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
  3. Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
  4. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
  5. Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
  6. 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 Any) As Long
  7. Private Declare Function RegRestoreKey Lib "advapi32.dll" Alias "RegRestoreKeyA" (ByVal hKey As Long, ByVal lpFile As String, ByVal dwFlags As Long) As Long
  8. Private Declare Function RegSaveKey Lib "advapi32.dll" Alias "RegSaveKeyA" (ByVal hKey As Long, ByVal lpFile As String, ByVal lpSecurityAttributes As Long) As Long
  9. 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 Any, lpcbData As Long) As Long
  10. Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByRef lpData As Any, lpcbData As Long) As Long
  11. 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, ByRef lpData As Any, ByVal cbData As Long) As Long
  12. Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
  13.  
  14. Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
  15. Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
  16. Private Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As Luid) As Long
  17. Private Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, ByVal PreviousState As Long, ByVal ReturnLength As Long) As Long
  18.  
  19. Private Const ERROR_SUCCESS = 0&
  20. Private Const ERROR_FILE_NOT_FOUND = 2&
  21.  
  22. Private Const KEY_QUERY_VALUE = &H1&
  23. Private Const KEY_SET_VALUE = &H2&
  24. Private Const KEY_CREATE_SUB_KEY = &H4&
  25. Private Const KEY_ENUMERATE_SUB_KEYS = &H8&
  26. Private Const KEY_NOTIFY = &H10&
  27. Private Const KEY_CREATE_LINK = &H20&
  28. Private Const READ_CONTROL = &H20000
  29. Private Const WRITE_DAC = &H40000
  30. Private Const WRITE_OWNER = &H80000
  31. Private Const SYNCHRONIZE = &H100000
  32. Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
  33. Private Const STANDARD_RIGHTS_READ = READ_CONTROL
  34. Private Const STANDARD_RIGHTS_WRITE = READ_CONTROL
  35. Private Const STANDARD_RIGHTS_EXECUTE = READ_CONTROL
  36. Private Const STANDARD_RIGHTS_ALL = &H1F0000
  37. Private Const KEY_READ = STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY
  38. Private Const KEY_WRITE = STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY
  39. Private Const KEY_EXECUTE = KEY_READ
  40. Private 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))
  41. Private Const REG_FORCE_RESTORE = &H8
  42. Private Const TOKEN_ADJUST_PRIVLEGES = &H20
  43. Private Const TOKEN_QUERY = &H8
  44. Private Const SE_PRIVILEGE_ENABLED = &H2
  45. Private Const SE_RESTORE_NAME = "SeRestorePrivilege"
  46. Private Const SE_BACKUP_NAME = "SeBackupPrivilege"
  47.  
  48. Private Type Luid
  49.    lowpart As Long
  50.    highpart As Long
  51. End Type
  52.  
  53. Private Type LUID_AND_ATTRIBUTES
  54.    pLuid As Luid
  55.    Attributes As Long
  56. End Type
  57.  
  58. Private Type TOKEN_PRIVILEGES
  59.    PrivilegeCount As Long
  60.    Privileges(1) As LUID_AND_ATTRIBUTES
  61. End Type
  62.  
  63. Public Enum rcMainKey
  64.    HKEY_CLASSES_ROOT = &H80000000
  65.    HKEY_CURRENT_USER = &H80000001
  66.    HKEY_LOCAL_MACHINE = &H80000002
  67.    HKEY_USERS = &H80000003
  68.    HKEY_PERFORMANCE_DATA = &H80000004
  69.    HKEY_CURRENT_CONFIG = &H80000005
  70.    HKEY_DYN_DATA = &H80000006
  71. End Enum
  72.  
  73. Public Enum rcRegType
  74.    REG_NONE = 0
  75.    REG_SZ = 1
  76.    REG_EXPAND_SZ = 2
  77.    REG_BINARY = 3
  78.    REG_DWORD = 4
  79.    REG_DWORD_LITTLE_ENDIAN = 4
  80.    REG_DWORD_BIG_ENDIAN = 5
  81.    REG_LINK = 6
  82.    REG_MULTI_SZ = 7
  83.    REG_RESOURCE_LIST = 8
  84.    REG_FULL_RESOURCE_DESCRIPTOR = 9
  85.    REG_RESOURCE_REQUIREMENTS_LIST = 10
  86. End Enum
  87.  
  88. Public Event SearchFound(ByVal key As String, ByVal Value As String, ByVal RegType As rcRegType, ByVal Data As Variant)
  89.  
  90. Private m_hToken        As Long
  91. Private m_TP            As TOKEN_PRIVILEGES
  92.  
  93. Private hKey             As Long
  94. Private mKey             As Long
  95. Private sKey             As String
  96. Private mFindInKey      As Boolean
  97. Private mFindInValue    As Boolean
  98. Private mFindInData     As Boolean
  99. Private mStrSearch      As String
  100. Private bCancelSearch   As Boolean
  101. Private m_bDoEvents     As Boolean
  102.  
  103. Public Sub SetSearchOption(ByVal sSearch As String, ByVal FindInKey As Boolean, ByVal FindInValue As Boolean, ByVal FindInData As Boolean, Optional ByVal CallDoEvents As Boolean)
  104.    mStrSearch = sSearch
  105.    mFindInKey = FindInKey
  106.    mFindInValue = FindInValue
  107.    mFindInData = FindInData
  108.    m_bDoEvents = CallDoEvents
  109. End Sub
  110.  
  111. Public Sub CancelSearch()
  112.    bCancelSearch = True
  113. End Sub
  114.  
  115. Public Sub StarSearch(ByVal sPath As String)
  116.    Dim i As Long
  117.    Dim ArrKeys() As Variant
  118.    bCancelSearch = False
  119.    If sPath = vbNullString Then
  120.        ArrKeys = Array("HKEY_CLASSES_ROOT", "HKEY_CURRENT_USER", "HKEY_LOCAL_MACHINE", "HKEY_USERS", "HKEY_CURRENT_CONFIG")
  121.        For i = 0 To 4
  122.            If bCancelSearch Then Exit Sub
  123.            If m_bDoEvents Then DoEvents
  124.            PvFindInValueAndData ArrKeys(i)
  125.            PvFindInKeys ArrKeys(i)
  126.        Next
  127.    Else
  128.        PvFindInValueAndData sPath
  129.        PvFindInKeys sPath
  130.    End If
  131. End Sub
  132.  
  133. Private Sub PvFindInKeys(ByVal sPath As String)
  134.    Dim lCount As Long
  135.    Dim sKeys() As String
  136.    Dim sCurPath As String
  137.    Dim i As Long
  138.  
  139.    lCount = EnumKeys(sPath, sKeys)
  140.  
  141.    If lCount Then
  142.        For i = 0 To lCount - 1
  143.            sCurPath = sPath & "\" & sKeys(i)
  144.  
  145.            If mFindInKey Then
  146.                If InStr(sKeys(i), mStrSearch) Then
  147.                    RaiseEvent SearchFound(sCurPath, vbNullString, REG_NONE, vbNull)
  148.                End If
  149.            End If
  150.  
  151.            If (mFindInValue = True) Or (mFindInData = True) Then
  152.                PvFindInValueAndData sCurPath
  153.            End If
  154.  
  155.            If bCancelSearch Then Exit Sub
  156.            If m_bDoEvents Then DoEvents
  157.            PvFindInKeys sCurPath
  158.        Next
  159.    End If
  160.  
  161. End Sub
  162.  
  163. Private Sub PvFindInValueAndData(sPath)
  164.    Dim lCount As Long
  165.    Dim sValue() As String
  166.    Dim lRegType() As Long
  167.    Dim sData() As Variant
  168.    Dim i As Long
  169.    Dim bFind As Boolean
  170.  
  171.    lCount = EnumValues(sPath, sValue, lRegType, sData, True)
  172.  
  173.    For i = 0 To lCount - 1
  174.        If bCancelSearch Then Exit Sub
  175.        If mFindInValue Then
  176.            If InStr(sValue(i), mStrSearch) Then
  177.                RaiseEvent SearchFound(sPath, sValue(i), lRegType(i), sData(i))
  178.                bFind = True
  179.            Else
  180.                bFind = False
  181.            End If
  182.        End If
  183.  
  184.        If mFindInData Then
  185.           If Not bFind Then
  186.                If InStr(sData(i), mStrSearch) Then
  187.                    RaiseEvent SearchFound(sPath, sValue(i), lRegType(i), sData(i))
  188.                End If
  189.            End If
  190.        End If
  191.    Next
  192. End Sub
  193.  
  194. Public Function CreateKey(ByVal sPath As String) As Boolean
  195.    hKey = GetKeys(sPath, sKey)
  196.  
  197.    If (RegCreateKey(hKey, sKey, mKey) = ERROR_SUCCESS) Then
  198.        RegCloseKey mKey
  199.        CreateKey = True
  200.    End If
  201. End Function
  202.  
  203. Public Function KillKey(ByVal sPath As String) As Long
  204.    Dim sKeys() As String, nKeys As Long, i As Long
  205.  
  206.    nKeys = EnumKeys(sPath, sKeys)
  207.    If nKeys > 0 Then
  208.        For i = 0 To nKeys - 1
  209.            KillKey sPath & "\" & sKeys(i)
  210.        Next i
  211.    End If
  212.  
  213.    hKey = GetKeys(sPath, sKey)
  214.  
  215.    If (RegOpenKey(hKey, sKey, mKey) = ERROR_SUCCESS) Then
  216.        KillKey = (RegDeleteKey(mKey, "") = ERROR_SUCCESS)
  217.        RegCloseKey mKey
  218.    End If
  219.  
  220. End Function
  221.  
  222. Public Function KeyExists(ByVal sPath As String) As Boolean
  223.    hKey = GetKeys(sPath, sKey)
  224.    If (RegOpenKey(hKey, sKey, mKey) = ERROR_SUCCESS) Then
  225.        KeyExists = True
  226.        RegCloseKey mKey
  227.    End If
  228. End Function
  229.  
  230.  
  231. Function RenameKey(ByVal sKeySource As String, ByVal sNewName As String) As Boolean
  232.    Dim hKeySource As Long
  233.    Dim hKeyDestination As Long
  234.    Dim sFile As String
  235.  
  236.    On Error GoTo ErrHandler
  237.  
  238.    sNewName = Mid(sKeySource, 1, InStrRev(sKeySource, "\")) & sNewName
  239.    hKey = GetKeys(sNewName, sKey)
  240.    sNewName = sKey
  241.    hKey = GetKeys(sKeySource, sKey)
  242.  
  243.    SetBackupAndRestorePriviliges
  244.    sFile = Environ$("Temp") & "\TempReg.reg"
  245.    If Len(Dir(sFile)) > 0 Then Kill sFile
  246.  
  247.    If (RegOpenKey(hKey, sKey, hKeySource) = ERROR_SUCCESS) Then
  248.        If (RegSaveKey(hKeySource, sFile, 0&) = ERROR_SUCCESS) Then
  249.            If (RegOpenKey(hKey, sNewName, hKeyDestination) = ERROR_FILE_NOT_FOUND) Then
  250.                If KillKey(sKeySource) = True Then
  251.                    If (RegCreateKey(hKey, sNewName, hKeyDestination) = ERROR_SUCCESS) Then
  252.                        RenameKey = (RegRestoreKey(hKeyDestination, sFile, REG_FORCE_RESTORE) = ERROR_SUCCESS)
  253.                    End If
  254.                End If
  255.                RegCloseKey hKeyDestination
  256.            End If
  257.        End If
  258.        RegCloseKey hKeySource
  259.    End If
  260.  
  261.    ResetBackupAndRestorePriviliges
  262.    If Len(Dir(sFile)) > 0 Then Kill sFile
  263. ErrHandler:
  264.  
  265. End Function
  266.  
  267. Public Function EnumKeys(ByVal sPath As String, ByRef key() As String) As Long
  268.    Dim sName As String, RetVal As Long
  269.  
  270.    hKey = GetKeys(sPath, sKey)
  271.  
  272.    Erase key
  273.  
  274.    If (RegOpenKey(hKey, sKey, mKey) = ERROR_SUCCESS) Then
  275.  
  276.        Do
  277.            sName = String(255, vbNullChar)
  278.            RetVal = Len(sName)
  279.  
  280.            If (RegEnumKeyEx(mKey, EnumKeys, sName, RetVal, ByVal 0&, vbNullString, ByVal 0&, ByVal 0&) <> ERROR_SUCCESS) Then Exit Do
  281.  
  282.            ReDim Preserve key(EnumKeys)
  283.            key(EnumKeys) = Left$(sName, RetVal)
  284.  
  285.            EnumKeys = EnumKeys + 1
  286.  
  287.        Loop
  288.  
  289.        RegCloseKey mKey
  290.    Else
  291.        EnumKeys = -1
  292.    End If
  293. End Function
  294.  
  295. Public Function HaveSubKey(ByVal sPath As String) As Boolean
  296.    Dim sName As String, RetVal As Long
  297.  
  298.    hKey = GetKeys(sPath, sKey)
  299.  
  300.    If (RegOpenKey(hKey, sKey, mKey) = ERROR_SUCCESS) Then
  301.        sName = String(255, 0)
  302.        RetVal = Len(sName)
  303.        HaveSubKey = (RegEnumKeyEx(mKey, 0, sName, RetVal, ByVal 0&, vbNullString, ByVal 0&, ByVal 0&) = ERROR_SUCCESS)
  304.        RegCloseKey mKey
  305.    End If
  306. End Function
  307.  
  308. Public Function CreateValue(ByVal sPath As String, ByVal sName As String, ByVal nType As rcRegType) As Boolean
  309.    hKey = GetKeys(sPath, sKey)
  310.    If (RegOpenKey(hKey, sKey, mKey) = ERROR_SUCCESS) Then
  311.        CreateValue = (RegSetValueEx(mKey, sName, 0, nType, 0&, 0&) = ERROR_SUCCESS)
  312.        RegCloseKey mKey
  313.    End If
  314. End Function
  315.  
  316. Public Function KillValue(ByVal sPath As String, ByVal sName As String) As Boolean
  317.  
  318.    hKey = GetKeys(sPath, sKey)
  319.  
  320.    If (RegOpenKey(hKey, sKey, mKey) = ERROR_SUCCESS) Then
  321.        KillValue = (RegDeleteValue(mKey, sName) = ERROR_SUCCESS)
  322.        RegCloseKey mKey
  323.    End If
  324.  
  325. End Function
  326.  
  327. Public Function ValueExists(ByVal sPath As String, ByVal sName As String) As Boolean
  328.  
  329.    hKey = GetKeys(sPath, sKey)
  330.  
  331.    If (RegOpenKey(hKey, sKey, mKey) = ERROR_SUCCESS) Then
  332.        ValueExists = (RegQueryValueEx(mKey, sName, 0&, 0&, ByVal 0&, 0&) = ERROR_SUCCESS)
  333.        RegCloseKey mKey
  334.    End If
  335.  
  336. End Function
  337.  
  338. Public Function RenameValue(ByVal sPath As String, ByVal sName As String, ByVal sNewName As String) As Boolean
  339.    Dim lLenBuff As Long
  340.    Dim bData() As Byte
  341.    Dim lType As Long
  342.  
  343.  
  344.    hKey = GetKeys(sPath, sKey)
  345.  
  346.    If (RegOpenKey(hKey, sKey, mKey) = ERROR_SUCCESS) Then
  347.        If RegQueryValueEx(mKey, sName, 0, lType, ByVal 0&, lLenBuff) = ERROR_SUCCESS Then
  348.           If lLenBuff Then
  349.                ReDim bData(lLenBuff - 1)
  350.                If (RegQueryValueEx(mKey, sName, 0, REG_BINARY, bData(0), lLenBuff) = ERROR_SUCCESS) Then
  351.                    If RegSetValueEx(mKey, sNewName, 0, lType, bData(0), lLenBuff) = ERROR_SUCCESS Then
  352.                        RenameValue = (RegDeleteValue(mKey, sName) = ERROR_SUCCESS)
  353.                    End If
  354.                End If
  355.            Else
  356.                If (RegSetValueEx(mKey, sNewName, 0, lType, 0&, 0&) = ERROR_SUCCESS) Then
  357.                    RenameValue = (RegDeleteValue(mKey, sName) = ERROR_SUCCESS)
  358.                End If
  359.            End If
  360.        End If
  361.        RegCloseKey mKey
  362.    End If
  363. End Function
  364.  
  365. Public Function EnumValues(ByVal sPath As String, ByRef sValue() As String, ByRef lRegType() As Long, ByRef vData() As Variant, Optional ByVal ReturnString As Boolean) As Long
  366.    Dim sValueName As String
  367.    Dim LenName As Long
  368.    Dim LenData As Long
  369.    Dim Index As Long
  370.    Dim EnuRegType As rcRegType
  371.  
  372.  
  373.    Erase sValue
  374.    Erase vData
  375.    Erase lRegType
  376.  
  377.    hKey = GetKeys(sPath, sKey)
  378.  
  379.    If hKey = 0 Then EnumValues = -1: Exit Function
  380.  
  381.    If RegOpenKey(hKey, sKey, mKey) = ERROR_SUCCESS Then
  382.  
  383.        Do
  384.            sValueName = String(255, vbNullChar)
  385.            LenName = Len(sValueName)
  386.  
  387.            If (RegEnumValue(mKey, Index, ByVal sValueName, LenName, 0, EnuRegType, ByVal 0&, LenData) = ERROR_SUCCESS) Then
  388.                sValueName = Left$(sValueName, LenName)
  389.                ReDim Preserve sValue(Index)
  390.                ReDim Preserve vData(Index)
  391.                ReDim Preserve lRegType(Index)
  392.  
  393.                sValue(Index) = sValueName
  394.                lRegType(Index) = EnuRegType
  395.  
  396.                Select Case EnuRegType
  397.                    Case REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ
  398.                        Dim sData As String
  399.                        If LenData > 0 Then
  400.                            sData = String(LenData - 1, vbNullChar)
  401.                            Call RegQueryValueEx(mKey, sValueName, 0, EnuRegType, ByVal sData, LenData)
  402.                            vData(Index) = sData
  403.                        Else
  404.                            vData(Index) = vbNullString
  405.                        End If
  406.  
  407.                    Case REG_DWORD
  408.                        Dim lVal As Long
  409.                        lVal = 0
  410.                        Call RegQueryValueEx(mKey, sValueName, 0, EnuRegType, lVal, 4)
  411.                         vData(Index) = lVal
  412.                    Case REG_BINARY
  413.                        Dim ArrData() As Byte
  414.                        If LenData > 0 Then
  415.                            If ReturnString Then
  416.                                sData = String(LenData, vbNullChar)
  417.                                Call RegQueryValueEx(mKey, sValueName, 0, EnuRegType, ByVal sData, LenData)
  418.                                vData(Index) = sData
  419.                            Else
  420.                                ReDim ArrData(LenData - 1)
  421.                                Call RegQueryValueEx(mKey, sValueName, 0, EnuRegType, ArrData(0), LenData)
  422.                                vData(Index) = ArrData
  423.                            End If
  424.                        End If
  425.  
  426.                End Select
  427.  
  428.                Index = Index + 1
  429.            Else
  430.                Exit Do
  431.            End If
  432.        Loop
  433.  
  434.        RegCloseKey hKey
  435.        EnumValues = Index
  436.    Else
  437.        EnumValues = -1
  438.    End If
  439.  
  440. End Function
  441.  
  442. Public Function ReadValue(ByVal sPath As String, ByVal sName As String, Optional vDefault As Variant = vbNullChar) As Variant
  443.    Dim LenData As Long
  444.    Dim EnuRegType As rcRegType
  445.  
  446.  
  447.    hKey = GetKeys(sPath, sKey)
  448.  
  449.    If (RegOpenKey(hKey, sKey, mKey) = ERROR_SUCCESS) Then
  450.  
  451.        If (RegQueryValueEx(mKey, sName, 0, EnuRegType, ByVal 0&, LenData) = ERROR_SUCCESS) Then
  452.  
  453.            Select Case EnuRegType
  454.                Case REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ
  455.                    Dim sData As String
  456.                    If LenData > 0 Then
  457.                        sData = String$(LenData - 1, vbNullChar)
  458.                        If (RegQueryValueEx(mKey, sName, 0, EnuRegType, ByVal sData, LenData) = ERROR_SUCCESS) Then
  459.                            ReadValue = sData
  460.                        Else
  461.                            ReadValue = CStr(vDefault)
  462.                        End If
  463.                    Else
  464.                        ReadValue = vbNullString
  465.                    End If
  466.  
  467.                Case REG_DWORD
  468.                    Dim lVal As Long
  469.  
  470.                    If (RegQueryValueEx(mKey, sName, 0, EnuRegType, lVal, 4) = ERROR_SUCCESS) Then
  471.                        ReadValue = lVal
  472.                    Else
  473.                        ReadValue = CLng(vDefault)
  474.                    End If
  475.  
  476.                Case REG_BINARY
  477.                    Dim ArrData() As Byte
  478.                    If LenData > 0 Then
  479.                        ReDim ArrData(LenData - 1)
  480.                        If (RegQueryValueEx(mKey, sName, 0, EnuRegType, ArrData(0), LenData) = ERROR_SUCCESS) Then
  481.                            ReadValue = ArrData
  482.                        Else
  483.                            ArrData = vDefault
  484.                        End If
  485.                    Else
  486.                        ArrData = vDefault
  487.                    End If
  488.  
  489.            End Select
  490.        End If
  491.        RegCloseKey mKey
  492.    End If
  493. End Function
  494.  
  495. Public Function WriteValue(ByVal sPath As String, ByVal sName As String, ByVal vValue As Variant) As Boolean
  496.    Dim LenData As Long
  497.    Dim bData() As Byte
  498.    Dim EnuRegType As rcRegType
  499.    Dim lRet As Long
  500.  
  501.    hKey = GetKeys(sPath, sKey)
  502.  
  503.    If (RegOpenKey(hKey, sKey, mKey) = ERROR_SUCCESS) Then
  504.  
  505.        If sName = vbNullString Then
  506.            EnuRegType = REG_SZ
  507.        Else
  508.            lRet = RegQueryValueEx(mKey, sName, 0, EnuRegType, ByVal 0&, LenData)
  509.        End If
  510.  
  511.        If (lRet = ERROR_SUCCESS) Then
  512.            Select Case EnuRegType
  513.                Case REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ
  514.  
  515.                    LenData = Len(vValue)
  516.  
  517.                    If RegSetValueEx(mKey, sName, 0, EnuRegType, ByVal CStr(vValue), LenData) = ERROR_SUCCESS Then
  518.                        WriteValue = True
  519.                    End If
  520.  
  521.                Case REG_DWORD
  522.                    If RegSetValueEx(mKey, sName, 0, EnuRegType, CLng(vValue), 4) = ERROR_SUCCESS Then
  523.                        WriteValue = True
  524.                    End If
  525.                Case REG_BINARY
  526.                    Select Case VarType(vValue)
  527.                        Case (vbArray Or vbByte)
  528.                            bData = vValue
  529.                            LenData = UBound(bData) + 1
  530.                            If RegSetValueEx(mKey, sName, 0, EnuRegType, bData(0), LenData) = ERROR_SUCCESS Then
  531.                                WriteValue = True
  532.                            End If
  533.                        Case vbString
  534.                            LenData = Len(vValue)
  535.                            If RegSetValueEx(mKey, sName, 0, EnuRegType, ByVal CStr(vValue), LenData) = ERROR_SUCCESS Then
  536.                                WriteValue = True
  537.                            End If
  538.                        Case 0
  539.                            If RegSetValueEx(mKey, sName, 0, EnuRegType, 0&, 0&) = ERROR_SUCCESS Then
  540.                                WriteValue = VarType(vValue)
  541.                            End If
  542.                    End Select
  543.  
  544.            End Select
  545.        End If
  546.        RegCloseKey mKey
  547.    End If
  548.  
  549. End Function
  550.  
  551.  
  552. Private Function GetKeys(sPath As String, sKey As String) As rcMainKey
  553.    Dim Pos As Long, mk As String
  554.  
  555.    sPath = Replace$(sPath, "HKCR", "HKEY_CLASSES_ROOT", , , 1)
  556.    sPath = Replace$(sPath, "HKCU", "HKEY_CURRENT_USER", , , 1)
  557.    sPath = Replace$(sPath, "HKLM", "HKEY_LOCAL_MACHINE", , , 1)
  558.    sPath = Replace$(sPath, "HKUS", "HKEY_USERS", , , 1)
  559.    sPath = Replace$(sPath, "HKCC", "HKEY_CURRENT_CONFIG", , , 1)
  560.  
  561.    Pos = InStr(1, sPath, "\")
  562.  
  563.    If (Pos = 0) Then
  564.        mk = UCase$(sPath)
  565.        sKey = ""
  566.    Else
  567.        mk = UCase$(Left$(sPath, Pos - 1))
  568.        sKey = Right$(sPath, Len(sPath) - Pos)
  569.    End If
  570.  
  571.    Select Case mk
  572.        Case "HKEY_CLASSES_ROOT": GetKeys = HKEY_CLASSES_ROOT
  573.        Case "HKEY_CURRENT_USER": GetKeys = HKEY_CURRENT_USER
  574.        Case "HKEY_LOCAL_MACHINE": GetKeys = HKEY_LOCAL_MACHINE
  575.        Case "HKEY_USERS": GetKeys = HKEY_USERS
  576.        Case "HKEY_CURRENT_CONFIG": GetKeys = HKEY_CURRENT_CONFIG
  577.    End Select
  578.  
  579. End Function
  580.  
  581.  
  582. Private Sub SetBackupAndRestorePriviliges()
  583.    Dim m_RestoreLuid   As Luid
  584.    Dim m_BackupLuid    As Luid
  585.  
  586.    Call OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVLEGES Or TOKEN_QUERY, m_hToken)
  587.    Call LookupPrivilegeValue(vbNullString, SE_RESTORE_NAME, m_RestoreLuid)
  588.    Call LookupPrivilegeValue(vbNullString, SE_BACKUP_NAME, m_BackupLuid)
  589.  
  590.    m_TP.PrivilegeCount = 2
  591.    m_TP.Privileges(0).pLuid = m_RestoreLuid
  592.    m_TP.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
  593.    m_TP.Privileges(1).pLuid = m_BackupLuid
  594.    m_TP.Privileges(1).Attributes = SE_PRIVILEGE_ENABLED
  595.  
  596.    Call AdjustTokenPrivileges(m_hToken, 0, m_TP, Len(m_TP), 0&, 0&)
  597.  
  598. End Sub
  599.  
  600. Private Sub ResetBackupAndRestorePriviliges()
  601.    Call AdjustTokenPrivileges(m_hToken, 1, m_TP, Len(m_TP), 0&, 0&)
  602. End Sub
  603.  
  604. Private Sub Class_Terminate()
  605.    bCancelSearch = True
  606. End Sub
  607.  
  608.  

Si me puedes decir un breve ejemplo para listar las carpetas del registro

Saludos! espero ayuda detallada de como utilizar tu modulo. Muchas gracias por leer!


En línea

illuminat3d

Desconectado Desconectado

Mensajes: 231



Ver Perfil WWW
Re: Duda con proyecto de Leandro Ascierto
« Respuesta #1 en: 14 Marzo 2016, 19:26 pm »

Ya logre hacerlo funcionar el modulo, es bastante sencillo la verdad le tenia que haber metido mas tiempo para verlo ;)
Perdonen tema cerrado.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[fix] como hacer que el cWidget.cls trabaje en vista (gracias a Leandro!)
Programación Visual Basic
el_c0c0 2 2,008 Último mensaje 5 Diciembre 2008, 01:11 am
por seba123neo
SkinForm.dll by Leandro y el_c0c0
Programación Visual Basic
ssccaann43 © 6 2,899 Último mensaje 12 Enero 2009, 14:54 pm
por ssccaann43 ©
Leandro Socket and Multithread
Programación Visual Basic
ntaryl 1 2,323 Último mensaje 6 Mayo 2010, 21:23 pm
por LeandroA
Duda acerca de un proyecto
Java
darmorir 0 1,393 Último mensaje 1 Febrero 2014, 15:08 pm
por darmorir
duda sobre proyecto.
Desarrollo Web
Drewermerc 4 2,165 Último mensaje 1 Septiembre 2014, 02:38 am
por Drewermerc
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines