I have a bool function that checks for the existence of a registry key:
private bool KeyExists(RegistryKey RootKey, string subKeyName)
{
RegistryKey ret = RootKey.OpenSubKey(subKeyName);
if (ret == null) {return false;}
else { return true; }
}
In my code,
if (!KeyExists(Registry.ClassesRoot, (@"\CLSID\{3BDAAC43-E734-11D5-93AF-00105A990292}")))
{
//create the subkey;
}
The key, copied from regedit is
HKEY_CLASSES_ROOT\CLSID\{3BDAAC43-E734-11D5-93AF-00105A990292}
Even though the key exists, the function, KeyExists() always returns false.
If I replace the call to KeyExists() thusly:
if (!KeyExists(Registry.LocalMachine, (@"SOFTWARE\Microsoft\")))
The function returns true.
Unlike all the examples I've found here and elsewhere, I'm checking for a CLSID and I'm pretty sure I'm not passing the parameter correctly.