繁体   English   中英

获取注册表项值

[英]Get a registry key value

我正在尝试从注册表中检索excel的版本,但我在使用时遇到了问题

Registry.GetValue(...)方法

我试图检索的值是在HKEY_CLASS_ROOT \\ Excel.Application \\ CurVer但我不知道在GetValue方法中作为参数放置什么名称。

我试过了 :

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

但是我一直在GetValue上得到一个NullReferenceException

版本号是默认值。

要得到这个,你需要:

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

return subKey.GetValue(""); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM