![]() |
Exception writing to registry... why?
I am using a bit of code in C# to write a simple string value to the registry with very very little luck, it keeps trowing an exception every single time saying I do not have write access to the registery, or it can not write to the registry (I forget extactly)... this is the offending code:
:
RegistryKey registryKey = Registry.CurrentUser;the tempdir value already exists within the registry, basically all I am doing is overwriting it, I tried deleting it first but as soon as Delete is called it says that it can not write the registry... is there something I am doing wrong here? Any ideas as to what could be causing this error? I am running the application as an administrator, and it can read the value without any problems... but since it is HKCU there should be no problems, even if I am not the administrator when writing to this key. Any help would be greatly appreciated. |
Oh yeah, I feel dumb for this one.... the problem is actually with OpenSubKey( "..." ); This function is overloaded and that is the ReadOnly form of the function... OpenSubKey( "...", true ); is how the function is called to open the key with write permissions.. took me an entire day to figure this one out, lol.
|
Just need to make sure what you have is exactly like the examples. They almost always work. :p
|
Actually I failed to realize that the problem was with that function to begin with. i thought it was a permission problem or a problem with the set value function. It was not until I did a bit of searching though google that I saw an example that used a second value for the OpenSubKey function, and then it all made sense.
|
| All times are GMT -5. The time now is 12:57 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC