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.
What used to be called simply “the value of a registry key” (for since there was only one, there was no need to give it a name) now goes by the special name the default value: It's the value whose name is null.
Use the GetValue method, specifying the path and name) to read a value from registry key. The following example reads the value Name from HKEY_CURRENT_USER\Software\MyApp and displays it in a message box.
The possible types for a registry value are: string (REG_SZ or REG_MULTI_SZ), expandable string (REG_EXPAND_SZ), integer (REG_DWORD) and binary (REG_BINARY).
Instead of using "(Default)"
, you'll need to use an empty string (""
).
using (var key = Registry.ClassesRoot.OpenSubKey(@"Excel.Application\\CurVer"))
{
var defvalue = key?.GetValue("");
if (defvalue != null)
{
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With