BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

req: please change implementation of "tRegistry"

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Non-Technical
View previous topic :: View next topic  
Author Message
Arthur Hoornweg
Guest





PostPosted: Fri May 14, 2004 7:46 am    Post subject: req: please change implementation of "tRegistry" Reply with quote



The standard access rights of the tRegistry class
(key_all_access) are set too high, so that an
"openkey" on HKLM fails on WinXP/Win2003, even
for powerusers.

It would be more appropriate to change the default value
of fAccess to (key_write or key_read).

Submitted as QC 8164



--
Arthur Hoornweg
(please remove the ".net" from my e-mail address)
Back to top
Arthur Hoornweg
Guest





PostPosted: Fri May 14, 2004 10:48 am    Post subject: Re: please change implementation of "tRegistry" Reply with quote



Craig van Nieuwkerk wrote:

Quote:
I think the TRegistry class is a fairly simple wrapper around the Registry
API, so you can easily get around it in the meantime.

Yes I can and will, but there's literally hundreds of
modules I have to checkout. I'd rather not change the
original VCL code and risk that future updates of D7
won't install.

Moreover, I have the impression that Borland's
"key_all_access" constant doesn't seem to match
Microsoft's definition of it.

Microsoft's definition (platform sdk, feb. 2003) is:

KEY_ALL_ACCESS :
Combination of KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS,
KEY_NOTIFY, KEY_CREATE_SUB_KEY, KEY_CREATE_LINK, and
KEY_SET_VALUE access.


Borland's version also includes write_owner,write_dac,
read_control and _Delete which is stuff for changing
ownership etcetera (who the heck needs that???) so a
poweruser has insufficient rights to read HKLM.



--
Arthur Hoornweg
(please remove the ".net" from my e-mail address)

Back to top
Craig van Nieuwkerk
Guest





PostPosted: Fri May 14, 2004 3:16 pm    Post subject: Re: please change implementation of "tRegistry" Reply with quote



I think the TRegistry class is a fairly simple wrapper around the Registry
API, so you can easily get around it in the meantime.

Quote:
The standard access rights of the tRegistry class
(key_all_access) are set too high, so that an
"openkey" on HKLM fails on WinXP/Win2003, even
for powerusers.

It would be more appropriate to change the default value
of fAccess to (key_write or key_read).

Submitted as QC 8164



--
Arthur Hoornweg
(please remove the ".net" from my e-mail address)



Back to top
Thomas J. Theobald
Guest





PostPosted: Fri May 14, 2004 3:16 pm    Post subject: Re: please change implementation of "tRegistry" Reply with quote

Sounds like you should have made a few registry functions and isolated them,
rather than copy the methods throughout the whole project...

T


Back to top
Colin Wilson
Guest





PostPosted: Fri May 14, 2004 3:35 pm    Post subject: Re: req: please change implementation of "tRegistry" Reply with quote

Arthur Hoornweg wrote:

Quote:
The standard access rights of the tRegistry class
(key_all_access) are set too high, so that an
"openkey" on HKLM fails on WinXP/Win2003, even
for powerusers.

Yes. It's annoying. But you can override this in the constructor,
which takes an optional AccessRights parameter.

eg.

var
reg : TRegistry;
begin
reg := TRegistry.Create (KEY_READ or KEY_WRITE);
try
reg.RootKey = HKEY_LOCAL_MACHINE;
if reg.OpenKey ('SoftwareBorland', False) then
begin
end
finally
reg.Free
end
end;


--
Colin - using XanaNews HTTP Transport
e-mail :colin (AT) wilsonc (DOT) demon.co.uk
web: http://www.wilsonc.demon.co.uk/delphi.htm

Posted with XanaNews 1.16.3.1

Back to top
Steve Trefethen (Borland
Guest





PostPosted: Fri May 14, 2004 3:37 pm    Post subject: Re: please change implementation of "tRegistry" Reply with quote

Arthur Hoornweg wrote:
Quote:

Yes I can and will, but there's literally hundreds of
modules I have to checkout. I'd rather not change the
original VCL code and risk that future updates of D7
won't install.

Moreover, I have the impression that Borland's
"key_all_access" constant doesn't seem to match
Microsoft's definition of it.

From winnt.h:

#define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |
KEY_QUERY_VALUE |
KEY_SET_VALUE |
KEY_CREATE_SUB_KEY |
KEY_ENUMERATE_SUB_KEYS |
KEY_NOTIFY |
KEY_CREATE_LINK)
&
(~SYNCHRONIZE))

From Windows.pas

KEY_ALL_ACCESS = (STANDARD_RIGHTS_ALL or
KEY_QUERY_VALUE or
KEY_SET_VALUE or
KEY_CREATE_SUB_KEY or
KEY_ENUMERATE_SUB_KEYS or
KEY_NOTIFY or
KEY_CREATE_LINK) and not
SYNCHRONIZE;

Looks the same to me.

I'm not saying that TRegistry shouldn't change but it requires a bit
more investigation than I have right now. So, please make sure this
gets into QualityCentral ([url]http://qc.borland.com)[/url].

Btw, why is this in non-tech? Followup set to
b.p.d.vcl.components.using.win32

Thanks
--
-Steve
Delphi.NET/C#Builder R&D
Borland Software Corporation
http://homepages.borland.com/strefethen

Back to top
Rick Francken
Guest





PostPosted: Fri May 14, 2004 7:48 pm    Post subject: Re: please change implementation of "tRegistry" Reply with quote

Run Regedit. Got to the HKLM key and right-click on it. Select
"Permissions..." to see if Power Users are included. If Power Users are
included check if they have more than Read access. IIRC, these permissions
are much tighter in XP and 2003 than in NT or 2000, so that by default only
Administrator and System accounts have more than Read access.

This is a change in the Operating System, not the TRegistry class. If you
do not specifically grant Write permissions on the keys in HKLM for the User
or Power User account, the program will not be able to write to that key.



"Arthur Hoornweg" <arthur.hoornweg (AT) wanadoo (DOT) nl.net> wrote

Quote:
The standard access rights of the tRegistry class
(key_all_access) are set too high, so that an
"openkey" on HKLM fails on WinXP/Win2003, even
for powerusers.

It would be more appropriate to change the default value
of fAccess to (key_write or key_read).




Back to top
Arthur Hoornweg
Guest





PostPosted: Mon May 17, 2004 6:34 am    Post subject: Re: please change implementation of "tRegistry" Reply with quote

Thomas J. Theobald wrote:

Quote:
Sounds like you should have made a few registry functions and isolated them,
rather than copy the methods throughout the whole project...

But I did! Every project has classes that implement
methods like:

Procedure tmyclass.Openreg;
Begin
registry:=tregistry.create;
registry.rootkey:=hkey_local_machine;
registry.openkey(myApplicationkey,true);
//myapplicationkey=Application specific constant
end;

Procedure tmyclass.Closereg;
Begin
registry.closekey;
registry.free;
end;

.... but this doesn't change anything about the problem
(having to check a LOT of units)...

Besides, the handling of tregistry is so small, it
doesn't really make sense to wrap this tiny VCL class
into yet another tiny class...




--
Arthur Hoornweg
(please remove the ".net" from my e-mail address)

Back to top
Arthur Hoornweg
Guest





PostPosted: Mon May 17, 2004 6:43 am    Post subject: Re: please change implementation of "tRegistry" Reply with quote

Rick Francken wrote:

Quote:
Run Regedit. Got to the HKLM key and right-click on it. Select
"Permissions..." to see if Power Users are included. If Power Users are
included check if they have more than Read access. IIRC, these permissions
are much tighter in XP and 2003 than in NT or 2000, so that by default only
Administrator and System accounts have more than Read access.

This is a change in the Operating System, not the TRegistry class.


I agree that it is (power users indeed have no write access under
HKLM under my windows XP). Still I think it makes sense to change
the default "key_all_access" because the "openkey" itself fails.




--
Arthur Hoornweg
(please remove the ".net" from my e-mail address)

Back to top
Rick Francken
Guest





PostPosted: Mon May 17, 2004 2:42 pm    Post subject: Re: please change implementation of "tRegistry" Reply with quote

Quote:


I agree that it is (power users indeed have no write access under
HKLM under my windows XP). Still I think it makes sense to change
the default "key_all_access" because the "openkey" itself fails.


No. The RootKey by default is HKEY_CURRENT_USER, and KEY_ALL_ACCESS is
consistent with that setting. If you explicitly change the RootKey to HKLM,
you must also deal explicitly with access permissions, one way or the other.
The reason "OpenKey" fails is because you pass CanCreate as true, and
Creating a key is not permitted.

If you are only reading from that key change this from:

registry.openkey(myApplicationkey,true);
to:
registry.openkey(myApplicationkey,false);

Or better still, call:
registry.OpenKeyReadOnly(myApplicationKey);

If you have to write to the key, it does not matter how you set the access,
it will fail if the user does not have sufficient access according to the
Windows operating system settings. You will either have to change the key
location to HKEY_CURRENT_USER, or you will have to grant Full Access to
Power Users for that key in HKEY_LOCAL_MACHINE.

Given that you have hundreds of modules coded the way you have coded them,
it sounds like the best initial approach is to let your Installer program
set the permission levels at install-time, as most installers can run with
elevated privileges.

Again, this has nothing to do with the TRegistry class.

Good luck,


-Rick Francken



Back to top
Colin Wilson
Guest





PostPosted: Thu May 20, 2004 11:15 pm    Post subject: Re: please change implementation of "tRegistry" Reply with quote

Arthur Hoornweg wrote:

Quote:
Procedure tmyclass.Openreg;
Begin
registry:=tregistry.create;

I still don't understand why you do this. Why not do...


Quote:
Procedure tmyclass.Openreg;
Begin
registry:=tregistry.create (KEY_READ or KEY_WRITE);

???

Then all your problems are solved - without any extra classes!


--
Colin
e-mail :colin (AT) wilsonc (DOT) demon.co.uk
web: http://www.wilsonc.demon.co.uk/delphi.htm

Posted with XanaNews 1.16.3.1

Back to top
eshipman
Guest





PostPosted: Fri May 21, 2004 3:28 pm    Post subject: Re: please change implementation of "tRegistry" Reply with quote

In article <xn0diirjb12ob6000 (AT) newsgroups (DOT) borland.com>,
[email]colin (AT) wilsonc (DOT) demon.co.uk[/email] says...
Quote:
Arthur Hoornweg wrote:

Procedure tmyclass.Openreg;
Begin
registry:=tregistry.create;

I still don't understand why you do this. Why not do...


Procedure tmyclass.Openreg;
Begin
registry:=tregistry.create (KEY_READ or KEY_WRITE);

???

Then all your problems are solved - without any extra classes!


Speaking of registry mods, your TEXRegistry unit needed a little
reworking to work with the new version 5 Regedit files.

I will send you the mods...

E.



Back to top
eshipman
Guest





PostPosted: Fri May 21, 2004 3:31 pm    Post subject: Re: please change implementation of "tRegistry" Reply with quote

<SNIP>
Quote:

Speaking of registry mods, your TEXRegistry unit needed a little
reworking to work with the new version 5 Regedit files.

I will send you the mods...

On another note Colin, please check out the post titled:

"Funny thing about those reg files" in b.p.d.l.d.win32.
It pertains to your usage of TFileStream to import reg files
in your TExRegistry unit on XP.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Non-Technical All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.