Solved

Registry.RegistryConnect

Posted on 2002-06-17
4
286 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 50 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

623 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