Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using GetValueNames on rootkey

Posted on 2002-06-11
3
Medium Priority
?
801 Views
Last Modified: 2012-05-04
I'm connecting to a remote registry on a LAN using RegistryConnect and need to find out the names of the subkeys under the HKEY_USERS key.

I've been using this code...

RootKey := HKEY_USERS;
RegistryConnect(Mchn);
GetKeyNames(Subs);

where Mchn is the name of the computer I'm connecting to and Subs is TStrings

but GetKeyNames doesn't seem to work unless I add an extra line using OpenKey, eg

RootKey := HKEY_USERS;
RegistryConnect(Mchn);
OpenKey('.DEFAULT');
GetKeyNames(Subs);


It's Catch-22 - I need to use OpenKey to be able to GetKeyNames, but I need to use GetKeyNames to be able to specify a key to open.

Any solutions to this? Thanks in advance.
0
Comment
Question by:riccohb
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
raidos earned 800 total points
ID: 7070095
I just tried this, and it seems to do the job just fine.. =)

Const Mchn = '\\whatever';
Var
  Reg : TRegistry;
  SL : TStrings;
begin
  //TaskBar.BtnWidth := 80;
  Reg := TRegistry.Create;
  Reg.RegistryConnect(Mchn);
  Reg.RootKey := HKEY_USERS;
  If Reg.OpenKeyReadOnly('\') Then Begin
    SL := TStringList.Create;
    Reg.GetKeyNames(SL);
    ShowMessage(SL.Text);
    SL.Free;
  End;
  Reg.Free;
End;

Regards
//raidos
0
 
LVL 3

Expert Comment

by:raidos
ID: 7070178
Oops...

I have missplaced the RootKey...it should be above the RegistryConnect call..

//raidos
0
 

Author Comment

by:riccohb
ID: 7072857
Works like a charm. Many thanks.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

877 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