Get registry key value

I am trying to extract an excel version from the registry, but I am having problems using

Registry.GetValue(...) Method

The value I'm trying to retrieve is in HKEY_CLASS_ROOT \ Excel.Application \ CurVer But I donโ€™t know which name should be specified as a parameter in the GetValue method.

I tried:

 RegistryKey key = Registry.ClassesRoot; RegistryKey subKey = key.OpenSubKey(@"Excel.Application\CurVer"); // Also tried w/o the "\CurVer" return subKey.GetValue("CurVer"); 

But I keep getting NullReferenceException in GetValue

+4
source share
2 answers

The version number is the default.

For this you need:

 string s = reg.GetValue(null).ToString(); 
+16
source
 RegistryKey key = Registry.ClassesRoot; RegistryKey subKey = key.OpenSubKey(@"Excel.Application\CurVer"); return subKey.GetValue(""); 
+1
source

Source: https://habr.com/ru/post/1300625/


All Articles