Solved

Using GetValueNames on rootkey

Posted on 2002-06-11
3
772 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 200 total points
Comment Utility
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
Comment Utility
Oops...

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

//raidos
0
 

Author Comment

by:riccohb
Comment Utility
Works like a charm. Many thanks.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

11 Experts available now in Live!

Get 1:1 Help Now