Solved

Creating a registry key where EVERYONE has FULL CONTROL

Posted on 1998-07-02
5
429 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
[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
  • 2
5 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356938
0
 

Author Comment

by:belgianbasman
ID: 1356939
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
ID: 1356940
I'll try to translate it soon.
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 200 total points
ID: 1356941
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
ID: 1356942
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month10 days, 5 hours left to enroll

624 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