How to get the default value of key from the registry

Viewed 7511

I am trying get the (Default) key value from the HKEY_CLASSES_ROOT and the code snippet I tried is as below,

using (var key = Registry.ClassesRoot.OpenSubKey(@"Excel.Application\\CurVer"))
{
    var defvalue = key?.GetValue("(Default)");
    if (defvalue != null)
    {
    }
}

Always the defvalue is coming as null. I am not able trace out what mistake I am doing.

Could anyone please help me to resolve this.

2 Answers

You can also try with "String.Empty" to get "(Default)" value of registry instead of accessing "(Default)" in your code.

Related