The following example shows you how to check if a key in the Windows registry exists, in this case the key named Test which is situated in HKEY_CURRENT_USER\Software\Geekpedia.
using Microsoft.Win32;
RegistryKey RK = Registry.CurrentUser.OpenSubKey("Software\\Geekpedia\\Test");
if(RK != null)
{
// It's there
}
else
{
// It's not there
}
Registry.CurrentUser tells the program to use HKEY_CURRENT_USER. We use double backslashes to escape the slash in the registry path, but we can aswell use:
RegistryKey RK = Registry.CurrentUser.OpenSubKey(@"Software\Geekpedia\Test");