寻找向注册表插入值的建议

时间:2013-08-05 12:36:47

标签: c# windows-ce

我尝试在C#中将值插入到注册表中,如下所示:

RegistryKey key;
key = Registry.CurrentUser.CreateSubKey("HKEY_LOCAL_MACHINE\\Drivers\\BuiltIn\\Touch");
key.SetValue("InitialState", 0x4, RegistryValueKind.DWord);

但没什么好开心的

当我在HKEY_LOCAL_MACHINE\\Drivers\\BuiltIn\\Touch下手动插入 我插入值00000004 (Hexidecima)它可以工作

怎么做对了?

2 个答案:

答案 0 :(得分:1)

您的陈述中有明显的错误

您尝试使用CurrentUser RegistryKey在LocalMachine注册表配置单元中写入

RegistryKey key;
key = Registry.LocalMachine.CreateSubKey("Drivers\\BuiltIn\\Touch");
key.SetValue("InitialState", 0x4, RegistryValueKind.DWord);

答案 1 :(得分:0)

尝试关闭密钥:key.Close();如果我没记错的话,在调用close()之前,寄存器不会更新。这是MSDN:MSDN Add Registry Key