Solved

Using GetValueNames on rootkey

Posted on 2002-06-11
3
784 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
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

773 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