Results 1 to 3 of 3

Thread: Problems with 'RegEnumKey'

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    21
    Hello!
    I've a problem with the 'RegEnumKey'-Function. The function succeeds(it returns 0) but the third parameter(which returns the name of the subkey) is always empty!

    VB 6.0; VC++ 6.0; PERL; PASCAL; BASIC; PHP4; HTML; mySQL

  2. #2
    Lively Member
    Join Date
    Jun 1999
    Location
    East Anglia, England
    Posts
    73
    Hello,
    I hope this code helps you but I'm in a bit of a rush at the moment so I haven't checked it through correctly. Just add a command button to a form and paste the code in.
    Code:
    Option Explicit
    
    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 RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    
    Const HKEY_CURRENT_USER = &H80000001
    
    Private Sub Command1_Click()
        GetAllSubKeys
    End Sub
    
    Function GetAllSubKeys()
        Dim lResult As Long
        Dim lRegKey As Long
        Dim sBuff As String
        Dim lBuffSize As Long
        Dim lValue As Long
        
    
        lResult = RegOpenKey(HKEY_CURRENT_USER, "RemoteAccess\Profile", lRegKey)
        
        If lResult <> 0 Then Exit Function
        
        lValue = 0
        sBuff = Space(255)
        lBuffSize = 255
        
        While RegEnumKey(lRegKey, lValue, sBuff, lBuffSize) = 0
            Debug.Print Left(sBuff, lBuffSize)
            sBuff = Space(255)
            lBuffSize = 255
            lValue = lValue + 1
        Wend
        
        lResult = RegCloseKey(lRegKey)
    End Function
    Hope it helps,
    Desire

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    21
    Yes, your code really helped me. Thank you!!
    VB 6.0; VC++ 6.0; PERL; PASCAL; BASIC; PHP4; HTML; mySQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width