Deny the registry access

Description :


This code shows how to deny the registry access

Following is the namespaces


using System;
using Microsoft.Win32;
using System.Security.Permissions;


Following is the code to deny the registrypermission


class Class1 {
static void Main(string[] args) {
RegistryPermission MyPermission = new RegistryPermission(RegistryPermissionAccess.AllAccess,"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
MyPermission.Deny();

RegistryKey myRegKey=Registry.LocalMachine;
myRegKey=myRegKey.OpenSubKey ("SOFTWARE\\Microsoft\\WindowsNT\\CurrentVersion");

Object MyValue=myRegKey.GetValue("RegisteredOwner");
Console.WriteLine("OS Registered Owner: {0}",MyValue.ToString());
}
}



By
Nathan


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: