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 31181
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: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |