Solved

searching for a key in visual basic

Posted on 2004-03-26
6
222 Views
Last Modified: 2013-11-13
I'm trying to use visual basic to serarch for a speific key in the registry. I know it rewuires the use of an API call but I can't find one that does what I would like it to do.
0
Comment
Question by:jardooman
  • 2
6 Comments
 
LVL 22

Expert Comment

by:cookre
Comment Utility
The API call to use is RegEnumKeyEx.  Here's a sample:
http://www.estescentral.net/Documentation/api/ref/r/regenumkeyex.html
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
If you are on VB .NET, then you can use the RegistryKey class.
0
 

Author Comment

by:jardooman
Comment Utility
I am familiar with the regenumkey but I can only get it to go in one level. The key I'm trying to find is within a folder that I may not always know the name of.
0
 
LVL 22

Accepted Solution

by:
cookre earned 125 total points
Comment Utility
That's why you have to walk the registry tree, recursively calling RegEnumKeyEx on each sub-key.

something like this:
bool EnumNode(HKEY KeyToDo)
{
idx=0;
rc = RegEnumKeyEx(KeyToDo,idx,...);
while (rc==ERROR_SUCCESS)
        {
        if (this is the one you're looking for)
           {
           do something
           return true;
           }
        Open this subkey
        if (EnumNode(thissubkey))  {close subkey; return true;)
        close subkey
        idx+=1;
        }

}
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now