Solved

Creating a registry key where EVERYONE has FULL CONTROL

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 70
Performance of SQL statement 37 148
scroll down TListBox component in Delphi 1 44
Broadcast a message using ICS 2 51
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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