我正在尝试从注册表中检索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");
Run Code Online (Sandbox Code Playgroud)
但是我一直在GetValue上得到一个NullReferenceException
Chr*_*isF 16
版本号是默认值.
要得到这个,你需要:
string s = reg.GetValue(null).ToString();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6294 次 |
| 最近记录: |