I confess I’m new to C#. I am struggling with creating a method to delete a registry key using .NET. The method takes one string parameter which contains the complete key to be removed. Here’s a sample of what I’m trying to do that doesn’t work (obviously):
namespace NameHere
{
class Program
{
static void Main(string[] args)
{
RegistryKey hklm = Registry.LocalMachine;
hklm = hklm.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\")
string strKey=”Test123”;
string fullPath = hklm + "\\" + strKey;
deleteRegKey(fullPath);
}
static void deleteRegKey(string keyName)
{
Registry.LocalMachine.DeleteSubKey(keyName);
}
}
}
I’ve tried a few other iterations and googled for solutions but have, so far, been unable to put the pieces together. Any help would be greatly appreciated. Also, any explanation for why my lame attempt doesn’t work to help clarrify my knowledge gap would be awesome.