473,385 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

registry access

Hi
Here is the code:

this.regPath = @"Software\FileManager\" ;

System.Security.Permissions.RegistryPermission permissions =
new
System.Security.Permissions.RegistryPermission(Sys tem.Security.Permissions.RegistryPermissionAccess. AllAccess,
@"HKEY_LOCAL_MACHINE\" + regPath);

bool regPermissions =
System.Security.SecurityManager.IsGranted(permissi ons);

It always returns true. In fact when i try to access registry:

Microsoft.Win32.Registry.LocalMachine.CreateSubKey (regPath);

key.SetValue("Height", OpenForms.MainForm.Height);

I have got exception:

System.UnauthorizedAccessException: Access to the registry key
'HKEY_LOCAL_MACHINE\Software\FileManager' is denied.
Can anyone help me with that?
Jun 25 '06 #1
1 6511
PiotrKolodziej wrote:
Hi
Here is the code:

this.regPath = @"Software\FileManager\" ;

System.Security.Permissions.RegistryPermission permissions =
new
System.Security.Permissions.RegistryPermission(Sys tem.Security.Permissions.RegistryPermissionAccess. AllAccess, @"HKEY_LOCAL_MACHINE\" + regPath);

bool regPermissions =
System.Security.SecurityManager.IsGranted(permissi ons);

It always returns true. In fact when i try to access registry:

Microsoft.Win32.Registry.LocalMachine.CreateSubKey (regPath);
key.SetValue("Height", OpenForms.MainForm.Height);

I have got exception:

System.UnauthorizedAccessException: Access to the registry key
'HKEY_LOCAL_MACHINE\Software\FileManager' is denied.
Can anyone help me with that?


Hi,

Unfortunately, the code you are using is not testing the type of
access-control you're after. It's testing code access security
permissions. The difference being the type of access control you're after
is, "Is the current user allowed to modify this particular part of the
registry?" and your code is "Is this code allowed to call methods that
modify the registry?"

The answer is: Yes. Your code *is* allowed to call methods that modify the
registry, but as far as the *actual* modifications are concerned, they are
not allowed.

You'll need to take a look at the GetAccessControl() portion of the
RegistryKey class.

Hope this helps,
-- Tom Spink
Jun 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Blizard | last post by:
I know this topic has been discussed before but I couldn't find any thread more recent than about 18 months and was interested in what conclusions people had come to recently. Invariably 3...
0
by: vincemoon | last post by:
Below is an excerpt from my Registry Log, created by Redmon, showing the process whereby TweakUI added the compressed folder option to the new sub-menu in the right click context menu for open...
21
by: Kevin Swanson | last post by:
I'm attempting some remote registry manipulation via C#. I've written a test app to simply grab a specified key from a specified hive on a specified machine. The call to OpenSubKey is throwing...
3
by: techmaccoy | last post by:
I am trying to access a entry under HKEY_Current_USER/Software. In My code it List seven subkeys under there. Actually there are lot more and the entry i wanted to access in seen in the Registry,...
1
by: Yoshitha | last post by:
Hi I am developing web application through which i've to write and read the values from the registry. When i set impersonate property to "false" it is displaying exception " Requested Registry...
8
by: Al Kaufman | last post by:
I have a simple console app that uses: regSubKey = <some registry key> Dim reg As RegistryKey = Registry.ClassesRoot.OpenSubKey(regSubKey) Dim path As String path = CStr(reg.GetValue(""))
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
1
by: UK1967 | last post by:
I wrote a ASP.NET application (Windows 2003 Enterprise Server, IIS, .NET Framework 1.1). This application use the Windows (AD) account and impersonation. Some functions in this application contact,...
3
by: JB | last post by:
I am trying to access a registry key on computer like so: key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, computerName).OpenSubKey(Subkey); There are two keys I am trying to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.