?
Solved

Registry.RegistryConnect

Posted on 2002-06-17
4
Medium Priority
?
289 Views
Last Modified: 2010-04-04
I am trying to access a list of SID values on a remote server using TRegistry. This is the code:

Uses Registry;

procedure MyProc;
var
  MySList : TStringList;
  MyReg : TRegistry;
  i : Integer;
begin
  MyReg := TRegistry.Create;
  If MyReg.RegistryConnect('\\RemoteServer') then
  begin
    If MyReg.OpenKeyReadOnly('\HKEY_USERS') then
    begin
      MySlist := TStringList.Create;
      MyReg.GetKeyNames(MySList);
      {Do Something with the string list}
      MyReg.CloseKey;
      MySList.Free;
    end
    else
    ShowMessage('Cannot read HKEY_USERS on remote server');
  end;
  MyReg.Free;
end;

I receive the error that the key cannot be read. I can access these values using a component I downloaded. Unfortunately the component does not have the functionality to read key values- which I need later.
The 3rd party component allows a username and password to be provided for the remote server, I think this problem I am having could be a security one.
Could someone please inform me if this is the case or let me know if I am doing something else wrong. If this is a security problem then does anyone know how I can provide a username and password before connecting to the remote registry.
0
Comment
Question by:Rabster
[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
  • 3
4 Comments
 

Author Comment

by:Rabster
ID: 7083759
I have just realisted, with a bit of tinkering, that when I use registry connect my rootkey is as follows:

\\RemoteServer\HK_CURRENT_USER\{MYSID}

Does anyone know I can change the root key to
\\RemoteServer\HK_USERS

Using MyReg.Rootkey := HK_USERS would set it back to the local machine.
0
 

Author Comment

by:Rabster
ID: 7083773
I have just realisted, with a bit of tinkering, that when I use registry connect my rootkey is as follows:

\\RemoteServer\HK_CURRENT_USER\{MYSID}

Does anyone know I can change the root key to
\\RemoteServer\HK_USERS

Using MyReg.Rootkey := HK_USERS would set it back to the local machine.
0
 
LVL 3

Accepted Solution

by:
raidos earned 200 total points
ID: 7083831
From Delphi help:

Note:     Before calling RegistryConnect, an application must set the RootKey property for its registry object to HKEY_USERS or HKEY_LOCAL_MACHINE.

//Otherwise it will revert back to the Local machine.

Regards
//raidos
0
 

Author Comment

by:Rabster
ID: 7083851
I've been looking at this problem all day and the answer has been staring my right in the face. In the examples I done earlier the first bit of code I wrote after creating the registry wrapper was to set the rootkey to HKey_Users. In my last example I forgot to do this.
Thanks fo your help, the program is working now.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

718 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