473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Registry access

Hi,

My C# app uses the registry for storing DB params, but under Windows XP
SP2, a normal user cannot write to this key (a .NET exception is thrown
when the app is run, but only under this OS).
My question is, can a certain area of the registry get accessed by
normal users. The key I am currently using is:

SYSTEM\CurrentControlSet\Services\

Any help on this would be appreciated. I have already suggested that the
customer enable this key for access by the normal user, but that has not
been accepted :|

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
6 1701
hi,

can you post some code to write values int the regestry.
I'm intrested in this, i would like my program to startup when windows is
started

thanks Maarten

"Steven Blair" <st**********@btinternet.com> schreef in bericht
news:uQ**************@TK2MSFTNGP15.phx.gbl...
Hi,

My C# app uses the registry for storing DB params, but under Windows XP
SP2, a normal user cannot write to this key (a .NET exception is thrown
when the app is run, but only under this OS).
My question is, can a certain area of the registry get accessed by
normal users. The key I am currently using is:

SYSTEM\CurrentControlSet\Services\

Any help on this would be appreciated. I have already suggested that the
customer enable this key for access by the normal user, but that has not
been accepted :|

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2
Hi,

You want to see my registry code?

If so, here it is:

private static string REGISTRY_PATH =
@"SYSTEM\CurrentControlSet\Services\MyKey";

RegistryKey hklm = Registry.LocalMachine;
RegistryKey MyKey;

MyKey= hklm.OpenSubKey(REGISTRY_PATH,true);

MyKey.SetValue("DBName",m_DBName);

MyKey.Close();

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4
Thanks
I'll try it out

regards Maarten

"Steven Blair" <st**********@btinternet.com> schreef in bericht
news:eJ**************@TK2MSFTNGP09.phx.gbl...
Hi,

You want to see my registry code?

If so, here it is:

private static string REGISTRY_PATH =
@"SYSTEM\CurrentControlSet\Services\MyKey";

RegistryKey hklm = Registry.LocalMachine;
RegistryKey MyKey;

MyKey= hklm.OpenSubKey(REGISTRY_PATH,true);

MyKey.SetValue("DBName",m_DBName);

MyKey.Close();

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #5
In Windows 2000 and XP certain keys can only be written to if your code is
running with Administrator privileges. For example, HKEY_LOCAL_MACHINE. The
HKEY_CURRENT_USER key, however does not require Administrator privileges. You
may want to change your code to write your software preferences to something
like:
HKEY_CURRENT_USER\Software\<CompanyName>\<Product> Settings

One thing to be aware of, keys written to the HKEY_CURRENT_USER key are
bound to a user, so if one user logs in, runs your software that writes
settings to this key, logs out, and then another user logs in, those settings
are tied to the other user and will not be there for the new user. This may
be desirable depending on your situation.

My rule of thumb is, write static software settings that will not change
after your software has been installed in
HKEY_LOCAL_MACHINE\Software\<Company Name>\<Product>\Settings
Typically, an Admin will be installing the software and thus, your software
will be running with Admin privileges and your software will be able to write
to this key.

Write user preferences in
HKEY_CURRENT_USER\Software\<Company Name>\<Product>\Settings

Anything else, write in a config file.

It’s considered bad to make your users run your software all the time as
Admin since this fails the security rule of running with the least privileges
as possible.

Hope this helps.
Regards
"Steven Blair" wrote:
Hi,

My C# app uses the registry for storing DB params, but under Windows XP
SP2, a normal user cannot write to this key (a .NET exception is thrown
when the app is run, but only under this OS).
My question is, can a certain area of the registry get accessed by
normal users. The key I am currently using is:

SYSTEM\CurrentControlSet\Services\

Any help on this would be appreciated. I have already suggested that the
customer enable this key for access by the normal user, but that has not
been accepted :|

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #6
In addition to what dlgproc said, your should only ever write in the
SOFTWARE folders, never in SYSTEM.

"Steven Blair" <st**********@btinternet.com> wrote in message
news:uQ**************@TK2MSFTNGP15.phx.gbl...
Hi,

My C# app uses the registry for storing DB params, but under Windows XP
SP2, a normal user cannot write to this key (a .NET exception is thrown
when the app is run, but only under this OS).
My question is, can a certain area of the registry get accessed by
normal users. The key I am currently using is:

SYSTEM\CurrentControlSet\Services\

Any help on this would be appreciated. I have already suggested that the
customer enable this key for access by the normal user, but that has not
been accepted :|

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Blizard | last post by:
I know this topic has been discussed before but I couldn't find any thread more recent than about 18 months and was interested in what conclusions people had come to recently. Invariably 3...
0
by: vincemoon | last post by:
Below is an excerpt from my Registry Log, created by Redmon, showing the process whereby TweakUI added the compressed folder option to the new sub-menu in the right click context menu for open...
21
by: Kevin Swanson | last post by:
I'm attempting some remote registry manipulation via C#. I've written a test app to simply grab a specified key from a specified hive on a specified machine. The call to OpenSubKey is throwing...
3
by: techmaccoy | last post by:
I am trying to access a entry under HKEY_Current_USER/Software. In My code it List seven subkeys under there. Actually there are lot more and the entry i wanted to access in seen in the Registry,...
1
by: Yoshitha | last post by:
Hi I am developing web application through which i've to write and read the values from the registry. When i set impersonate property to "false" it is displaying exception " Requested Registry...
8
by: Al Kaufman | last post by:
I have a simple console app that uses: regSubKey = <some registry key> Dim reg As RegistryKey = Registry.ClassesRoot.OpenSubKey(regSubKey) Dim path As String path = CStr(reg.GetValue(""))
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
1
by: PiotrKolodziej | last post by:
Hi Here is the code: this.regPath = @"Software\FileManager\" ; System.Security.Permissions.RegistryPermission permissions = new...
1
by: UK1967 | last post by:
I wrote a ASP.NET application (Windows 2003 Enterprise Server, IIS, .NET Framework 1.1). This application use the Windows (AD) account and impersonation. Some functions in this application contact,...
3
by: JB | last post by:
I am trying to access a registry key on computer like so: key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, computerName).OpenSubKey(Subkey); There are two keys I am trying to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.