delete a key from Registry : Registry Save « Windows « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;


public class MainClass{

    static void Main(string[] args){
         string strKey;
         string strAns;
         Console.WriteLine("Enter the key under HKEY_CURRENT_USER to delete");
         strKey = Console.ReadLine();
         Console.WriteLine("Do you really mean to delete: " + strKey + " and its settings?");
         strAns = Console.ReadLine();
         strAns = strAns.ToUpper();
         if (strAns == "YES" | strAns == "Y")
         {
               Registry.CurrentUser.DeleteSubKeyTree(strKey);
               Console.WriteLine("Key " + strKey + " deleted");
         }
         else
         {
               Console.WriteLine("No deletion performed");
         }
    }
}








29.2.Registry Save
29.2.1.Save int value to Registry
29.2.2.Set DateTime value to the Registry
29.2.3.Set String value to the Registry
29.2.4.Save user prefs to registry
29.2.5.delete a key from Registry
29.2.6.Delete a setting in Registry