[英]Reading registry key
我有一个可以在Win 7(X86)计算机上进行编译和调试的应用程序。 它可以在Windows 7(X64)计算机上安装并正常运行,但是如果在编译后尝试调试,则会出现异常。 这是引发异常的代码:
public static string ReadLocalMachineRegistryKeyValue(string stringSubKey, string stringValue)
{
string stringReadValue = "";
try
{
RegistryKey regKey;
regKey = Registry.LocalMachine.OpenSubKey(stringSubKey);
if (regKey != null)
{
stringReadValue = regKey.GetValue(stringValue).ToString();
}
else
{
throw new Exception("No such Subkey found.");
}
}
catch (Exception ex)
{
throw ex;
}
return stringReadValue;
}
知道为什么它会在安装后编译并运行,但无法在64位计算机上调试吗? 可能很重要的一点是,将鼠标悬停在regKey变量上时,分配给它的值是准确的。 regKey永远不会获取该值,它保持为空。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.