Solved

Creating a registry key where EVERYONE has FULL CONTROL

Posted on 1998-07-02
5
387 Views
Last Modified: 2010-04-04
The first time my program is run, it stores some values like in wich directory to store its files in the registry under HKEY_LOCAL_MACHINE, because all users that login afterwards should be able to access these values.  It works fine when the user who is logged in at that time is an administrator.
Now after the installation a normal user without administrator privileges logs on, tries to run the program, and then the program cannot find the settings stored in HKEY_LOCAL_MACHINE. When he goes into the registry with the Registry Editor THE KEY IS THERE ! He can even DELETE it !

I've found that the problem lies in the security settings for this key.  User Group "Everyone" has limited (or special) access to this key, so anyone who is not an administrator cannot find the key from within the Delphi app.
So, to make a long story short, here is the question:....

"How do I create a registry key from within a Delphi program where EVERYONE has FULL CONTROL ?"

Obviously, the Delphi-method TRegistry.CreateKey is not going to work. I think I'll have to use the API -call RegCreateKeyEx and provide a lpSecurityAttributes that contains a valid SecurityDescriptor.  I don't know how to do this.  Any help would be really appreciated.

Anyone who can give me a working example code will receive the highest possible score.
0
Comment
Question by:belgianbasman
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
0
 

Author Comment

by:belgianbasman
Comment Utility
To Ronit:

Thank you so much.  This is great. Just what I needed.  I've been searching all over the internet for this.

Would you happen to have some examples of this in Delphi Code ? That would be really great.  I'd be happy to give you the 200 points for it.  I think now I'd have to compile this in C++ and then call that from Delphi one way or the other, so native Delphi code would really help me out.

Thanks anyway, you've been a great help.  :)
0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
I'll try to translate it soon.
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 200 total points
Comment Utility
I have translated part of the code which refers to the security, Hope this helps a bit:

const
  SECURITY_DESCRIPTOR_REVISION = 1; // not defined by Delphi
var
  pSD: PSecurityDescriptor;
  sa: PSecurityAttributes ;
begin
  GetMem(pSD, SECURITY_DESCRIPTOR_MIN_LENGTH);
  if pSD=nil then Exit;
  if not InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION) then Exit;
  if not SetSecurityDescriptorDacl(pSD, TRUE, nil, FALSE) then Exit;
  sa.nLength:=sizeof(sa);
  sa.lpSecurityDescriptor:=pSD;
  sa.bInheritHandle:=TRUE;
  RegCreateKeyEx(..., sa,...);
  FreeMem(pSD);
end;

see also Delphi code in:
http://developers.href.com/ARTICLE:572736439:waArticle.146531
0
 

Author Comment

by:belgianbasman
Comment Utility
Thank you very much.  I still have to test the code, but I'm quite confident I'll manage with these examples to build on.
If you should find any more info on this subject in the future, I would very much appreciate to receive a copy  at   dverdonck@kiss.nl

Cheers,

Dirk
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

12 Experts available now in Live!

Get 1:1 Help Now