Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this code
VB
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("Software", False)
regKey.CreateSubKey("MyApp")
regKey.Close()
MsgBox("Registry key HKLM\Software\MyApp created")

in windows xp its all ok but in
windows 8 64bit I have this error message
"An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll"
Does anyone have an example code for windows 8.1 64 bit

Thanks
Posted
Updated 6-Jun-14 22:23pm
v3

Don't use the registry.
Beginning in Vista, access has become more and more restricted because it was abused and became badly bloated. Writing to the registry needs elevated permissions - which means UAE - which is a poor choice for anything new.

Have a look here: Where should I store my data?[^] - it suggests some safer places to store information.
 
Share this answer
 
try below code
VB
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", True)
regKey.CreateSubKey("MyApp")
regKey.Close()


check the documentation of RegistryKey.OpenSubKey Method (String, Boolean)[^]
you need to give true value as writable parameter. otherwise you open as read only mode
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900