|
-
Mar 14th, 2004, 12:05 PM
#1
Thread Starter
Hyperactive Member
registry security from .net
hi,
just wonder if somebody has a perspective.
I am attempting to try out in c# some of the things was happy with in VB6....
I have looked for many code samples and to read the registry I am using something like
Code:
RegistryKey testkey = Registry.LocalMachine.OpenSubKey("Software", true);
I have tried load of slighty different code - always I get a System.Security.SecurityException from mscorlib.dll.
I am a local admin of the machine I am running on and can regedit to the key I am viewing.
questions
- do .net form apps run in the context of the user involking them?
or
- is there additional security on the registry calls (over and above the usual reg-key protection that I can play with via Regedt32)
or am I just barking mad!!
cheers AJP
-
Mar 14th, 2004, 05:14 PM
#2
Sleep mode
Well , your .NET application verifies the security attributes it has to the local machine security , if access is denied then your app shut down immediately throwing security exception . However , since you have admin privilages then this is not a problem . You need more security code to gain access to some reg keys though .
PHP Code:
private string LoadRegSettings()
{
string subkey="";
RegistryKey regkey;
try
{
regkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\YourAppName\Settings");
subkey =regkey.GetValue("AnyValueYouSetHereIsRetrieved").ToString();
regkey.Close();
}
catch
{
MessageBox.Show("subkey is empty");
}
return subkey;
}
I'm using this code and it works good , even for regular user permissions .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|