Solved

Using GetValueNames on rootkey

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 103
Why does formely good SQL code in Delphi 2009 not work under Windows 10? 5 87
creating threads in delphi 1 80
CheckListBox usage 3 48
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…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

10 Experts available now in Live!

Get 1:1 Help Now