Results 1 to 5 of 5

Thread: Read Registry Keys

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Read Registry Keys

    I want to search a section of the registry, and change keys after the key is read, how do I do that?

    For example: I want to read all of the keys that are to open on Windows reboot, and add them to a listbox.

    I can read 1 key just fine, but how do I change keys?

    Thanks,
    Sir Loin
    Last edited by Sir Loin; Jun 20th, 2005 at 08:45 PM.

  2. #2
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    Re: Changing Files

    The attached module has an example of enumerating all subkeys at the top of it.

    edit

    It also has an example of getting all of the values in any given subkey
    Attached Files Attached Files
    Last edited by anotherVBnewbie; Jun 20th, 2005 at 08:15 PM. Reason: Correction

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Changing Files

    Change your thread title - it's misleading ...

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    537

    Re: Read Registry Keys

    Thanks, it works great!

    I have one question though, what is lKeyValue's purpose in this code, its value is 0, right? but the code doesn't work if you replace Ikeyvalue with 0's, why?

    VB Code:
    1. Public Function ReadRegistryGetSubkey(ByVal Group As Long, ByVal Section As String, Idx As Integer) As String
    2.     Dim lResult As Long, lKeyValue As Long, lDataTypeValue As Long, lValueLength As Long, sValue As String, td As Double
    3.     On Error Resume Next
    4.     lResult = RegOpenKey(Group, Section, lkeyvalue)
    5.     sValue = Space$(2048)
    6.     lValueLength = Len(sValue)
    7.     lResult = RegEnumKey(lKeyValue, Idx, sValue, lValueLength)
    8.     If (lResult = 0) And (Err.Number = 0) Then
    9.         sValue = Left$(sValue, InStr(sValue, Chr(0)) - 1)
    10.     Else
    11.         sValue = "Not Found"
    12.     End If
    13.     lResult = RegCloseKey(lKeyValue)
    14.     ReadRegistryGetSubkey = sValue
    15.    
    16. End Function


    Thanks,
    SIR LOIN

  5. #5
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    Re: Read Registry Keys

    lKeyValue is a variable and once it reads the registry key it will be changed from 0 to some other number. If you type 0 in it's place it won't work.
    CodeBank: Launch IE

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