c++ - 更改 key 后的 "Refreshing"Windows 注册表

标签 c++ windows winapi registry

案例:

  1. 注册表项的 DWORD 值为 0
  2. 将注册表键值更改为 1
  3. 再读一遍值:还是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/

相关文章:

c++ - 为什么主类模板中的成员未在专用类的范围内声明?

c++ - 如何忽略来自 _CrtDumpMemoryLeaks 的误报内存泄漏?

c++ - 计算字符串中的多字符字符

android - 如何使用 Android.bp 文件构建(Soong 构建系统)

c++ - 为什么我没有收到 WM_MENUCHAR 消息?

c++ - 如何获取窗口中的显示数量?

c++ - 如何计算作为输出打印的字符数?

windows - WMI Win32_PerfRawData_PerfOS_PagingFile PercentUsage 图中的可疑值

c++ - 是否可以恢复在挂起的 I/O 操作中使用的已分配的 OVERLAPPED 结构?

windows - Windows 上的 OpenGL ICD 如何加载 OpenGL 1.0 和 1.1 功能?