How to allow my some of users to access to windows registry

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear All,

I have some PCes run on Windows 2000 SP4, they are member of PDC , for some
of purposes my Vb.NET application needs to write to windows registry, How to
allow my some of users to access to windows registry ?.. please advise

many thanks in advance

Regards
Winanjaya
 
Could you make the question a little more specific. Is your question

1. How to set security on specific registry keys such that users can access
them?
Good app design practice is to write user specific registry values into
HKEY_CURRENT_USER so that you don't actually have to setup special
permissions to write into the registry.

2. What calls do you need to access the registry
..NET framework has a Registry class that can be used in VB .NET
http://msdn.microsoft.com/library/d...tml/frlrfMicrosoftWin32RegistryClassTopic.asp
 
Thanks for your prompt reply, FYI, my vb.net app is commercial app, my app
writes to windows registry (ie. to HKEY_CLASSES_ROOT ..for security purposes)
... do you have any idea regarding on this? .. please advise

Regards
Winanjaya
 
For HKCR the correct assumption to make is that the installer (running under
elevated privilege) will set up the correct registry entries.

Specifically

Machine wide settings in HKCR - (Do it once using through the installer
where you can expect it to run under an account with administrative
privileges)
If you application stores one time keys in HKLM (Do it in the installer)
If you application has to read and write during execution into HKLM (Split
the application into client/service and document the fact that the service
will need a privileged account)
If you app needs per user settings (use HKCR no restrictions here)


--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subjected to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
 
Hi .. you wrote:
If you app needs per user settings (use HKCR no restrictions here), may be
you meant HKCU ? ..if my app writes to HKCU then how if more than one people
using that PC? .. please advise ..

Regards
Winanjaya
 
Sorry I meant HKCU.

The second part of your question I don't understand fully but here goes

Case 1: Suppose you want to store personalization information for a user
(and there is not a enough of it to merit a file).

You app would check HKCU\Software\yourapp\somekey if it does not exist it
will create the key. Since the HKCU hive is different for each user only the
customization of the user running the app will be read from the registry.
You can do this within the application code because every user can write to
their HKCU

Case 2: Suppose you want to store some personal information but also write
information common to all users

If you want to write to machine wide state for an application the better
thing to do is have a configuration file (say config.xml) and put the path
to the file as part of setup in HKLM. Since you can specify that application
installation requires administrative privileges you can do it as part of the
installer. Secondly as part of the installer you would set permissions on
config.xml so all app users can write to it.

The alternative (create a registry key under HKLM and allow all users to
write to it) is possible but it is far easier and scalable (especially with
XML) to use files for this purpose. If you do want to create a key with
special permissions then the one call you could use (Win32 unfortunately) is
RegSetKeySecurity

Case 3: You have a requirement where you have to dynamically write to HKCR
or HKLM
I can't think of scenarios where you cannot work around this. If you have
one tell me and I'll let you know if there is a work around. In the worst
case you are down to using the win32 call above in your installer.

Hope I am not answering a completely different question.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subjected to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
 
Back
Top