Solved

Using GetValueNames on rootkey

Posted on 2002-06-11
3
798 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
raidos earned 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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