Solved

Creating a registry key where EVERYONE has FULL CONTROL

Posted on 1998-07-02
5
394 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
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

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

16 Experts available now in Live!

Get 1:1 Help Now