Click here to Skip to main content
14,641,834 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have this code
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
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

try below code
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
   
v4

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100