?
Solved

protecting a registry entry

Posted on 1999-11-11
17
Medium Priority
?
254 Views
Last Modified: 2010-04-04
Hello there,

I'm setting a registry entry (CurrentVersion/Run) and after that I would like to protect this entry, so that users can't delete it!

(just protecting one key / entry).

Is this possible?
Please help.
0
Comment
Question by:florisb
  • 7
  • 4
  • 2
  • +4
17 Comments
 
LVL 7

Expert Comment

by:RBertora
ID: 2199818
following..
0
 
LVL 1

Expert Comment

by:King_David
ID: 2199910
As far as I know you can't.
What I do is save these settings in the
exe file.
0
 
LVL 2

Author Comment

by:florisb
ID: 2199919
The idea is that users shouldn;t be able to remove the entry under .../run

saving / checking in the .exe is no use if the .exe doesn't autostart....:-)

Anybody an idea?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
LVL 1

Expert Comment

by:King_David
ID: 2199933
I wouldn't want a program stacked in
my autostart without having the
possibility remve it.
0
 
LVL 2

Author Comment

by:florisb
ID: 2199949
I need to develop a program that can't be removed by normal users....
0
 
LVL 3

Expert Comment

by:Slavak
ID: 2199985
listening...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2200112
You can use SetNamedSecurityInfo/SetSecurityInfo to protect registry keys - but only under winNT...

Regards, Madshi.
0
 
LVL 2

Author Comment

by:florisb
ID: 2200174
that's cool, I checked the msdn.. ..it should work like that... Could you give me one hint how to use this function in Delphi (is it in a dll???)

thanx....

I will accept the answer....

0
 
LVL 2

Author Comment

by:florisb
ID: 2200208
advapi32.dll .... ....trying....
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2200274
Entering...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2200288
type
  // must be 4 byte long (needed by NT security APIs)
  {$minenumsize 4}
    TSecurityObjectType = (seUnknown, seFile, seService, sePrinter, seRegistry,
                                      seShare, seKernelObject, seWindowObject);
  {$minenumsize 1}

var
  // winNT security function variables
  GetNamedSecurityInfoW : function (objectName   : PWideChar;
                                    objectType   : TSecurityObjectType;
                                    securityInfo : cardinal;
                                    sidOwner     : PPSid;
                                    sidGroup     : PPSid;
                                    dacl         : PPAcl;
                                    sacl         : PPAcl;
                                    var sd       : PSecurityDescriptor) : cardinal; stdcall = nil;
  SetNamedSecurityInfoW : function (objectName   : PWideChar;
                                    objectType   : TSecurityObjectType;
                                    securityInfo : cardinal;
                                    sidOwner     : PSid;
                                    sidGroup     : PSid;
                                    dacl         : PAcl;
                                    sacl         : PAcl) : cardinal; stdcall = nil;
  GetSecurityInfoW      : function (handle       : cardinal;
                                    objectType   : TSecurityObjectType;
                                    securityInfo : cardinal;
                                    sidOwner     : PPSid;
                                    sidGroup     : PPSid;
                                    dacl         : PPAcl;
                                    sacl         : PPAcl;
                                    var sd       : PSecurityDescriptor) : cardinal; stdcall = nil;
  SetSecurityInfoW      : function (handle       : cardinal;
                                    objectType   : TSecurityObjectType;
                                    securityInfo : cardinal;
                                    sidOwner     : PSid;
                                    sidGroup     : PSid;
                                    dacl         : PAcl;
                                    sacl         : PAcl) : cardinal; stdcall = nil;

var dll : dword;
begin
              dll := LoadLibrary(advapi32);
              // Windows unloads the library automatically when our program terminates...
              GetNamedSecurityInfoW := GetProcAddress(dll, 'GetNamedSecurityInfoW');
              SetNamedSecurityInfoW := GetProcAddress(dll, 'SetNamedSecurityInfoW');
                   GetSecurityInfoW := GetProcAddress(dll,      'GetSecurityInfoW');
                   SetSecurityInfoW := GetProcAddress(dll,      'SetSecurityInfoW');

Regards, Madshi.
0
 
LVL 2

Author Comment

by:florisb
ID: 2200320
When I try to add your code to my app, I have a few small problems:

PPSid en PPAcl undeclared

and

cannot initialize multiple.... on:
var sd       : PSecurityDescriptor) : cardinal; stdcall = nil;

I increased the point a bit. Could you help me a bit more....:-)

thanks,
Floris.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2200344
Sorry,

seems, I've forgotten some type declarations:

type
  PPAcl = ^PAcl;
  PPSid = ^PSid;

Regards, Madshi.
0
 
LVL 2

Author Comment

by:florisb
ID: 2200459
I do accept your comment.

but, do you mind to add an example call to these funtions?

Thanks,
Floris
0
 
LVL 1

Expert Comment

by:aldyn
ID: 2200503
I could recommend to use my SvCom components to deal with NT security. They operate with ACLs, SIDs, SECURITY_DESCRIPTORs and other fun staff. It allows to avoid a lot of API calls and memory reallocations that are necessary to adjust security. They are available at my site at http://members.tripod.com/~aldyn/svcom_frame.html
The set of examples is availabe at
http://members.tripod.com/~aldyn/tutorial/
0
 
LVL 20

Accepted Solution

by:
Madshi earned 360 total points
ID: 2200699
Please check aldyn's components first. If they do not help you, I'll look if I can give you a little example...
0
 
LVL 2

Author Comment

by:florisb
ID: 2200888
I'll check your links... ..thanks for the help!

Perhaps I'll ask something again, but here are your points
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

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

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…
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…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…

601 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