Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check if reg subkey is empty

Status
Not open for further replies.

jflaurin

Technical User
Dec 1, 2007
12

I'm using the following loop to get the content of reg keys and then add them to a list box, the problem is that
if a key is empty it gererates an error. How can I overcome this ?

Also Is there another way to do this beside looping 1000 times ? There's only 5-6 keys that have content at the time but they may be named anything between 1 - 1000 ( ie :
HKCR\Folder\shell\Use Zip _ Help\protect\folderpath1 or HKCR\Folder\shell\Use Zip _ Help\protect\folderpath999 )

------------------------------------

The code :

For r = 1 To 1000


folderpath = wsh.RegRead("HKCR\Folder\shell\Use Zip _ Help\protect\folderpath" & r)

foldername = wsh.RegRead("HKCR\Folder\shell\Use Zip _ Help\protect\foldername" & r)

lstfolder.ListItems.Add , , r

' now add the subitems to the listview
With lstfolder.ListItems(lstfolder.ListItems.Count)
.SubItems(1) = foldername
.SubItems(2) = folderpath
End With



Next r
 
Use in-line error handling

On Error Resume Next

If Err.number=0 then

else
err.clear
end if
 
thanks for the suggestion, tried it and it doesn't work :-(
 
In what sense doesn't it work? How are you implementing SBerthold's suggestion in your code?
 
Reading 1000 keys?

-David
2006 & 2007 Microsoft Most Valuable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top