Hi all,
i m trying to read registry root keys and their subkeys but there are some keys on which access is not allowed. For getting access to such keys, i used the following code where keypath is the path to that particular key to which i want to gain access, such as HKLM\ SAM. but it still not allows me to read that key and throws an exception "Registrykey access not allowed". so plz tell me a way to do this. thanks

RegistryPermission f = new RegistryPermission(
RegistryPermissionAccess.Read,
keypath);

Recommended Answers

All 3 Replies

you either can check permissions in regedit and grant the user, or if you impersonate the local system account that should work as well

is there any way to do this using c# code

yes, do a google search on c# impersonation

or use regedit to view permissions

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.