Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,810,679 Members 41,406 Now Online
XDA Developers Android and Mobile Development Forum

[C#] [VS2008] Registry - 'System.UnauthorizedAccessException'

Tip us?
 
cichy3000
Old
#1  
cichy3000's Avatar
Senior Member - OP
Thanks Meter 1
Posts: 195
Join Date: Feb 2008
Question [C#] [VS2008] Registry - 'System.UnauthorizedAccessException'

Hi all,
I'm writing application that will allow users to change values in TouchFlo Registry Settings ... Some touchflo improvements, and when app goes to doing this code:

Code:
RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\OEM\\TFLOSettings");
reg.SetValue("PageHigh", inputed_value);
i got : 'System.UnauthorizedAccessException' and app just crashes... :/

i would be really grateful, for helping me with it... how can i set value to the registry ?
 
[germany]merlot
Old
#2  
[germany]merlot's Avatar
Senior Member
Thanks Meter 0
Posts: 198
Join Date: Oct 2007
Quote:
Originally Posted by cichy3000 View Post
Code:
RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\OEM\\TFLOSettings");
reg.SetValue("PageHigh", inputed_value);
You need to open the registry key this way:

Code:
RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\OEM\\TFLOSettings", true);
reg.SetValue("PageHigh", inputed_value);
true means that you have write permission on the specified key. When you open the key as false you only have read permission.

PS: Please use next time the Q&A forum and Google.com
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes