المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Registry Editing



C# Programming
09-12-2009, 04:57 PM
I am trying a program to add keys, however i am getting an exception saying
System.UnauthorizedAccessException : Cannot write to registry key
You can consider me beginner in registry editing issue.
using System;
using System.Security.Permissions ;
using Microsoft.Win32;

public class RegistryEditor
{
public static void Main()
{
try
{
RegistryKey hkcu = Registry.CurrentUser;
RegistryKey hkSoftware = hkcu.OpenSubKey("Software");
RegistryKey hkMicrosoft = hkSoftware.OpenSubKey("Microsoft");
RegistryKey hkIshaan = hkSoftware.CreateSubKey("Test1");
hkIshaan.SetValue("Name", "Ishaan");
hkIshaan.SetValue("Age", "20");
hkIshaan.Close();
hkSoftware.Close();
hkcu.Close();
}
catch (Exception ex)
{
Console.Write(ex.ToString());
}
}
}

Banking establishment are more dangerous then standing armies.