Results 1 to 6 of 6

Thread: Getting All Values in Registery

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 1999
    Posts
    33

    Talking

    I've been searching and trying to figure out
    how to get all the values in a specific place
    in the registery, I need a code to retrieve
    both the Name and Data. Thanks in advance.

    Sincerely,
    Matthew Howle

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Have a look for the API call "RegEnumValue"

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 1999
    Posts
    33
    I got that part, but I just can't get the functions to work.

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Excuse any typing errors but I am having to copy this from a different screen without the lovely abilty to cut'n'paste :-(

    Code:
    Function ScanRegNode(sKeyName as String, ByRef colReturn as Collection, Optional hRoot as Long = HKEY_CURRENT_USER) as Long
    
      Dim lngKeyHandle as Long
      Dim lngResult as Long
      Dim lngCurIdx as Long
      Dim strValue as String
      Dim lngValueLen as Long
      Dim lngData as Long
      Dim lngDataLen as Long
      Dim strResult as String
    
      On Error Goto ScanError
      lngResult = RegOpenKeyEx(hRoot, sKeyName, 0&, KEY_READ, lngKeyHandle)
      If lngResult <> 0 ERROR_NONE Then
        Msgbox "Cannot Open Key"
        Exit Function
      End If
    
      lngCurIdx = 0
      Do
        lngValueLen = 2000
        strValue = String(lngValueLen, 0)
        lngDataLen = 2000
        lngResult = RegEnumValue(lngKeyHandle, lngCurIdx, ByVal strValue, lngValueLen, 0&, REG_WORD, ByVal lngData, lngDataLen)
        lngCurIdx = lngCurIdx + 1
        If lngResult = ERROR_NONE Then
          strResult = Left(strValue, lngValueLen)
          coReturn.Add Item:=strResult
        End If
      Loop While lngResult = ERROR_NONE
      RegCloseKey (lngKeyHandle)
    
      Exit Function
    
    ScanError:
      ScanRegNode = Err.Number
    End Function
    Of course you need to find out all the Constants and the declarations of the API's but that is straight forward.

    What this does is give you a collection of the keys that exist underneath the name you stated. From there you can cycle through each one and get the actual value.

    Does that help?

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 1999
    Posts
    33
    Yeah, thanks.

    This is new to me and all. Can you please explain
    the colReturn As Collection part? I just
    don't understand what's it asking for. Thanks again

  6. #6
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    colReturn is a collection which means you need to pass it a collection

    ie :

    Code:
    Dim cKeys as New Collection
    Dim i as Integer
    Dim sMsg as String
    
    If ScanRegNode("MyApp/Parameters", cKeys) = 0 Then
       For i = 1 to cKeys.Count
         sMsg = "Key #" & i & " is " & cKeys(i) & vbcr
       Next i
    
       msgbox sMsg
    End If
    A collection is like a linked list... it is a dynamically expanding array if you like

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