Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Error accessing Registry from Windows app

Reply
Thread Tools

Error accessing Registry from Windows app

 
 
Steve
Guest
Posts: n/a
 
      11-29-2003
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.All Access,
"HKEY_CURRENT_USER\SOFTWARE\MyApplication")
oKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey
("Software").OpenSubKey("MyApplication").OpenSubKe y
("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.
 
Reply With Quote
 
 
 
 
Paul Glavich
Guest
Posts: n/a
 
      11-30-2003
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.

--
- Paul Glavich


"Steve" <(E-Mail Removed)> wrote in message
news:002501c3b6a7$19f84300$(E-Mail Removed)...
> 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.All Access,
> "HKEY_CURRENT_USER\SOFTWARE\MyApplication")
> oKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey
> ("Software").OpenSubKey("MyApplication").OpenSubKe y
> ("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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java - accessing Windows Registry stanberka Java 0 03-20-2006 11:10 PM
How to read a registry key from Windows registry ? Leny Java 3 02-01-2005 07:54 AM
Error accessing the OLE registry error Wanda ASP General 2 08-12-2004 05:32 PM



Advertisments