Error accessing Registry from Windows app

S

Steve

When attempting to access the Registry, I receive errors.
I have attempted to add code to assert access to the key,
but this does not help. The documentation on accessing
the Registry is pathetic.

Dim rp As New
System.Security.Permissions.RegistryPermission
(Security.Permissions.RegistryPermissionAccess.AllAccess,
"HKEY_CURRENT_USER\SOFTWARE\MyApplication")
oKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey
("Software").OpenSubKey("MyApplication").OpenSubKey
("Database")
oKey.SetValue("Databases", "1")


Error Message:

An unhandled exception of
type 'System.UnauthorizedAccessException' occurred in
mscorlib.dll

Additional information: Cannot write to the registry key.
 
P

Paul Glavich

Use the Regedt32 tool (in Win2000) or Regedit (WinXP) to set read/write
access on the particular registry key for the user your are trying to access
with, or the group that the user(s) are a member of.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top