-
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!
-
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
-
Ok, that works good, but how can I know how many itmes are in the registry? It could be zero, could be 100...
Thanks!!
-
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.
-
OUTSTANDING!!
Thank you SO much for your help!
I REALLY appreciate it.