I have Visual Studio 2005 Express Edition. I am trying to change registry
value by:
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\My_app" );
key.SetValue(name_of_value, new_value_string);
I am getting error:
System.UnauthorizedAccessException: Cannot write to the registry key.
at System.ThrowHelper.ThrowUnauthorizedAccessExceptio n(ExceptionResource
resource)
at Microsoft.Win32.RegistryKey.SetValue(String name, Object value,
RegistryValueKind valueKind)
at Microsoft.Win32.RegistryKey.SetValue(String name, Object value)
at MyApp.Form1.MyFunction(String data, String name_of_value) in
C:\Documents and Settings\Admin\MyApp\MyApp\Form1.cs:line 70
what is wrong? 4 31194
To change the value you should be using CreateSubey instead of OpenSubKey
Eric Renken
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:E3**********************************@microsof t.com...
>I have Visual Studio 2005 Express Edition. I am trying to change registry
value by:
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\My_app" );
key.SetValue(name_of_value, new_value_string);
I am getting error:
System.UnauthorizedAccessException: Cannot write to the registry key.
at System.ThrowHelper.ThrowUnauthorizedAccessExceptio n(ExceptionResource
resource)
at Microsoft.Win32.RegistryKey.SetValue(String name, Object value,
RegistryValueKind valueKind)
at Microsoft.Win32.RegistryKey.SetValue(String name, Object value)
at MyApp.Form1.MyFunction(String data, String name_of_value) in
C:\Documents and Settings\Admin\MyApp\MyApp\Form1.cs:line 70
what is wrong?
"Eric Renken" <Er********@newsgroup.nospamwrote in message
news:O5**************@TK2MSFTNGP03.phx.gbl...
To change the value you should be using CreateSubey instead of OpenSubKey
Or at least use the OpenSubKey overload that allows you to request write
access. http://msdn2.microsoft.com/en-us/library/ms128501.aspx
>
Eric Renken
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:E3**********************************@microsof t.com...
>>I have Visual Studio 2005 Express Edition. I am trying to change registry value by:
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\My_app" ); key.SetValue(name_of_value, new_value_string);
I am getting error:
System.UnauthorizedAccessException: Cannot write to the registry key. at System.ThrowHelper.ThrowUnauthorizedAccessExcepti on(ExceptionResource resource) at Microsoft.Win32.RegistryKey.SetValue(String name, Object value, RegistryValueKind valueKind) at Microsoft.Win32.RegistryKey.SetValue(String name, Object value) at MyApp.Form1.MyFunction(String data, String name_of_value) in C:\Documents and Settings\Admin\MyApp\MyApp\Form1.cs:line 70 what is wrong?
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:E3**********************************@microsof t.com...
>I have Visual Studio 2005 Express Edition. I am trying to change registry
value by:
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\My_app" );
key.SetValue(name_of_value, new_value_string);
I am getting error:
System.UnauthorizedAccessException: Cannot write to the registry key.
at System.ThrowHelper.ThrowUnauthorizedAccessExceptio n(ExceptionResource
resource)
at Microsoft.Win32.RegistryKey.SetValue(String name, Object value,
RegistryValueKind valueKind)
at Microsoft.Win32.RegistryKey.SetValue(String name, Object value)
at MyApp.Form1.MyFunction(String data, String name_of_value) in
C:\Documents and Settings\Admin\MyApp\MyApp\Form1.cs:line 70
what is wrong?
.......OpenSubKey("Software\\My_app", true);
Willy.
When you use OpenSubKey you are opening registry keys in read-only mode. Just make this change to your code,
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\My_app" , true);
Good luck!!
EggHeadCafe.com - .NET Developer Portal of Choice http://www.eggheadcafe.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: firenet |
last post by:
Came in one morning and found that the following message appeared only on
running Access 2000, then the program shuts down, all other office 2000
applications work fine.
"Required registry...
|
by: Yogi_Bear_79 |
last post by:
I'm Creating new Keys in the registry, but when I do, they always have
a Vaule called (Default) type RG_SZ. I need them to be DWord
dword:00000005
Is there a way to automaticaly make the...
|
by: caldera |
last post by:
Hi,
I write a windows service. In that service I create a new subkey for registry. But service
install is call CreateSubKey() the program throw an exception to the event log said that
Cannot write...
|
by: ahaupt |
last post by:
Hi all,
I've created a setup project for my app in VS2003 and need to set up
some registry values and keys.
It is easy enough to just create static keys with static values, but
I'd like the...
|
by: scorpion53061 |
last post by:
Trying to change a value named in a remote registry. In this case we want to
set the password protect function of the screensaver so WMI can do a reboot
of the system. (IsSecure or...
| |
by: nikou_70 |
last post by:
I have a message in (LegalNoticeText) in winlogin in registry ,when
user( in our network) log to windows can see massage that I put in
LegalNoticeText , every day I should change this message(it's...
|
by: Patrick F |
last post by:
I keep getting this error message and i don't know whats the problem is and
how to solve it. I have a webproject with 2 components (dll) added to it. One
is called PhotoGallery and one is called...
|
by: Patrick F |
last post by:
I keep getting this error message and i don't know whats the problem is and
how to solve it. I have a webproject with 2 components (dll) added to it. One
is called PhotoGallery and one is called...
|
by: CDMAPoster |
last post by:
In:
http://groups.google.com/group/comp.databases.ms-access/msg/f06bd4c45037ef29
Lyle wrote:
:Terry Kreft wrote:
:
:>Suck it and See?
:
|
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,...
|
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,...
| |
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |