Using RegQueryKeys and Counting the Number of Subkeys
Keywords: regquerykeys
Question:
I am writing a program that searches through the registry to find different types of keys.Well, I use these three lines to search for subkeys within the current key that I am in:
keylevel = RegOpenKey(@REGMACHINE,string) string1 = RegQueryKeys(keylevel) RegCloseKey(keylevel)When dealing with the registry - some of the subkeys can be extremely long - One of them was 470 subkeys - so thats 470 long strings delimited by @tabAnyways, because of this I get Error 3096 - Memory Allocation Error. Out of Memory for Strings. This always happens when trying to extract one of the values from this super long list within a string.
Answer:
You are going to have to use RegQueryKey (Singlular) and grab the keys one at a time.Here's an example:
mainkey="SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\" subkeylist=RegQueryKeys(@REGMACHINE,mainkey) count=ItemCount(subkeylist,@tab) for xx=1 to count thissubkey=ItemExtract(xx,subkeylist,@tab) srvkey= strcat(mainkey,thissubkey, "[servicename]" thisname=RegQueryValue(@REGMACHINE,srvkey) Message(thissubkey,thisname) nextBefore 97A came out with RegQueryKeys, you could do the following:
regkey = RegOpenKey (@REGCURRENT, "wherever") l_REG_subkeys = "" For regcounter = 0 To 9999 ; Run through all subkeys (arbitrarily high number) mysubkey = RegQueryKey (regkey, regcounter) If (mysubkey == "") Then Break ; do actions on mysubkey or break if the ; right one found, depending on need. Next RegCloseKey (regkey)Because we were not working with the vast numbers of keys that you are, we switched to the cleaner RegQueryKeys as soon as we found it, but the above will work for your needs.
Article ID: W13735Filename: RegQueryKeys and Counting Subkeys.txt