Results 1 to 5 of 5

Thread: Read Registry Entries to a List Box

  1. #1

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Question

    I've never played in the Registry via code, so I need some help...

    I want to take entries from the registry and place them in a text box, but don't know how to begin.

    The registry path is as follows:
    HKEY_LOCAL_MACHINE\SOFTWARE\Vendor Name\Program Name\Domains\Banned

    and the entries will have sequential names, starting at 0 and increasing by 1. The values are IP addresses using from 1 to 4 nodes.

    Examples include:
    123.123.*.*
    123.255.255.123

    and so on...

    How can I load these IP's to a list box in my VB6 program?

    Thanks!
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    There's a sample project with full registry code here: http://www.parksie.uklinux.net/registry.zip

    Then, just loop through the items, and collect the addresses:
    Code:
    For i = 1 to 5
        List1.AddItem GetString(HKEY_CURRENT_USER, "Software\My Company\IPs", "IP" & i)
    Next i
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375
    Ok, that works good, but how can I know how many itmes are in the registry? It could be zero, could be 100...

    Thanks!!
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Quick hack version: check the response. If it's a null string, then it doesn't exist so break out of the loop. My code doesn't have anything in for counting the number of values. The registry API is no help because it only tells you the total number of values, not the number you want. The simplest way is probably to have a DWORD value, with the number of IP addresses present.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Talking

    OUTSTANDING!!

    Thank you SO much for your help!

    I REALLY appreciate it.
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

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