Advertisement
tolikpunkoff

DelRegValues

Feb 4th, 2021
1,516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Microsoft.Win32;
  5.  
  6. namespace DelRegValues
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string subkey = "Software\\TestKey";
  13.             RegistryKey key = null;
  14.  
  15.             try
  16.             {
  17.  
  18.                 key = Registry.CurrentUser.OpenSubKey(subkey, true);
  19.  
  20.                 foreach (string valname in key.GetValueNames())
  21.                 {
  22.                     Console.WriteLine("Delete value: " + valname);
  23.                     key.DeleteValue(valname);
  24.                 }
  25.  
  26.                 key.Close();
  27.             }
  28.             catch (Exception ex)
  29.             {
  30.                 Console.WriteLine("ERROR: " + ex.Message);
  31.             }
  32.  
  33.             Console.Write("Press enter...");
  34.             Console.ReadLine();
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement