我在 output1
和 output2
中得到了不同的结果。第一个给了我在注册表中实际看到的值,而后者只给了我默认值。我想念什么?
String output1 = Registry.GetValue(
@"HKEY_USERS\blobb", "beep", "nope!") as String;
String output2 = Registry.Users.GetValue(
@"blobb\beep", "nope!") as String;
我已经尝试了很多不同的输入字符串变体,但没有一个给我正确的值。
最佳答案
Registry.Users.GetValue
正在根 USERS 键中查找名为“blobb\beep”的值
要获得与第一个示例相同的结果,您需要类似的东西
using (var blobb = Registry.Users.OpenSubKey("blobb"))
{
String output2 = blobb.GetValue("beep", "nope!") as String
}
关于c# - Registry.GetValue() 和 Registry.User.GetValue() 的不同结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13290498/