Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Creating a registry key where EVERYONE has FULL CONTROL

Posted on 1998-07-02
5
Medium Priority
?
444 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 800 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

971 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