using System; using Microsoft.Win32; using System.Security.Permissions; class RegistreRefuserAcces { static void Main(string[] args) { RegistryPermission regPermission = new RegistryPermission(RegistryPermissionAccess.AllAccess,@"HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersion"); regPermission.Deny(); RegistryKey myRegKey=Registry.LocalMachine; myRegKey=myRegKey.OpenSubKey (@"SOFTWAREMicrosoftWindowsNTCurrentVersion"); Object oValue = myRegKey.GetValue("PathName"); Console.WriteLine("SE Pathname: {0}", oValue.ToString()); } }