RegistryKey.GetValue(..) returns 空

RegistryKey.GetValue(..) returns null

我正在尝试检索 (REG_SZ) 注册表项的值并将其写入字符串。但是这段代码似乎认为密钥为空或不存在,并且不允许我 GetValue() 它。这是我用来检索值的代码。

string s64BasePath = "SOFTWARE\Wow6432Node\Xactware\";
private void versionSelectorBox_SelectedIndexChanged(object sender, EventArgs e)
{
    showForms();
    sVersionSelected = versionServerBox.Text;
    if (b64Bit == true)
    {
        string sRKey = s64BasePath + sVersionSelected + "\"; //Reads as SOFTWARE\Wow6432Node\Xactware\Xactimate28\
        using (RegistryKey key = Registry.LocalMachine.OpenSubKey(sRKey))
        {
            if (key != null)
            {
                //label1.Text = "Test."; //Reaches this point just fine
                Object o = key.GetValue("Location");
                if (o != null)
                {
                    //label1.Text = "Test."; //Does not reach this point, o = null?
                    sLocationKey = Convert.ToString(o);
                }
            }
        }
        //label1.Text = sLocationKey;
}

这是注册表的样子。如您所见, Location 键存在于提供的路径中。然而,代码并没有落入最内层的 if 语句,就像 o 对象为空。

提前致谢。

老实说,在没有安装 Xactimate 的情况下,我没有与您相同的注册表项,所以我使用 Skype 作为我的密钥。

我改变了一件事,我把它从 \ 改为使用文字字符串标志。 仅供参考,我在 LINQPad 中 运行 所以忽略 'dump' 命令

var test = @"SOFTWARE\Wow6432Node\Skype\Phone";
var reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(test);
reg.Dump("OpenSubKey: ");
var result = reg.GetValue("SkypeFolder");
result.Dump("GetValue: ");

这是两个转储的结果