案例:
- 注册表项的 DWORD 值为 0
- 将注册表键值更改为 1
- 再读一遍值:还是0
必须重新启动程序才能读取新值。
我用谷歌搜索并查看了 CRegKey 类,但我没有看到任何可以回答我的问题的东西。我也知道 explorer.exe 必须在更改注册表后重新启动才能生效。
有什么方法可以在运行时获取注册表的新“拷贝”吗?
编辑:原来我上面的情况是完全不正确的。这是其他地方的错误,阻止我读取新值。
最佳答案
有一个函数:RegFlushKey()
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724867%28v=vs.85%29.aspx
也许这就是你要找的,但是这个函数应该被修改注册表的代码调用
以下是评论的摘录:
Calling RegFlushKey is an expensive operation that significantly affects system-wide performance as it consumes disk bandwidth and blocks modifications to all keys by all processes in the registry hive that is being flushed until the flush operation completes. RegFlushKey should only be called explicitly when an application must guarantee that registry changes are persisted to disk immediately after modification. All modifications made to keys are visible to other processes without the need to flush them to disk.
关于c++ - 更改 key 后的 "Refreshing"Windows 注册表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20910955/