protecting a registry entry

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.
LVL 2
florisbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RBertoraCommented:
following..
0
King_DavidCommented:
As far as I know you can't.
What I do is save these settings in the
exe file.
0
florisbAuthor Commented:
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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

King_DavidCommented:
I wouldn't want a program stacked in
my autostart without having the
possibility remve it.
0
florisbAuthor Commented:
I need to develop a program that can't be removed by normal users....
0
SlavakCommented:
listening...
0
MadshiCommented:
You can use SetNamedSecurityInfo/SetSecurityInfo to protect registry keys - but only under winNT...

Regards, Madshi.
0
florisbAuthor Commented:
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
florisbAuthor Commented:
advapi32.dll .... ....trying....
0
LischkeCommented:
Entering...
0
MadshiCommented:
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
florisbAuthor Commented:
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
MadshiCommented:
Sorry,

seems, I've forgotten some type declarations:

type
  PPAcl = ^PAcl;
  PPSid = ^PSid;

Regards, Madshi.
0
florisbAuthor Commented:
I do accept your comment.

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

Thanks,
Floris
0
aldynCommented:
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
MadshiCommented:
Please check aldyn's components first. If they do not help you, I'll look if I can give you a little example...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
florisbAuthor Commented:
I'll check your links... ..thanks for the help!

Perhaps I'll ask something again, but here are your points
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.