RegNotifyChangeKeyValue 是否像看起来那么粗糙?
我一直在使用 ReadDirectoryChangesW 来监视文件系统的特定部分。它很好地提供了更改的文件或目录的部分路径名以及有关更改性质的线索。这可能已经把我宠坏了。
我还需要监视注册表的特定部分,但看起来 RegNotifyChangeKeyValue
非常粗糙。它会告诉我给定键下的某些内容发生了变化,但它似乎不想告诉我该内容可能是什么。真糟糕!
有问题的注册表部分是任意深的,因此枚举所有子项并为每个子项调用 RegNotifyChangeKeyValue
可能不是一个好主意,因为我最终将不得不克服 MAXIMUM_WAIT_OBJECTS
。另外,我必须调整传递给 RegNotifyChangeKeyValue
的键集,这将需要付出相当大的努力,而无需每次都枚举子键,这将导致大量的失败的目的。
有什么想法吗?
I've been using ReadDirectoryChangesW
to monitor a particular portion of the file system. It rather nicely provides a partial pathname to the file or directory which changed along with a clue about the nature of the change. This may have spoiled me.
I also need to monitor a particular portion of the registry, but it looks as if RegNotifyChangeKeyValue
is very coarse. It will tell me that something under the given key changed, but it doesn't seem to want to tell me what that something might have been. Bummer!
The portion of the registry in question is arbitrarily deep, so enumerating all the sub-keys and calling RegNotifyChangeKeyValue
for each probably isn't a hot idea because I'll eventually end up having to overcome MAXIMUM_WAIT_OBJECTS
. Plus I'd have to adjust the set of keys I'd passed to RegNotifyChangeKeyValue
, which would be a fair amount of effort to do without enumerating the sub-keys every time, which would defeat a fair amount of the purpose.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,是的。您可能必须缓存代码感兴趣的所有值,并在收到更改触发器时自行更新此缓存,或者设置多个观察者,每个观察者关注感兴趣的单个数据项。正如您所指出的,第二个解决方案很快就会变得笨拙。
如果您可以在 .Net 中实现所需的代码,则可以通过 RegistryEvent 及其子类。
Unfortunately, yes. You probably have to cache all the values of interest to your code, and update this cache yourself whenever you get a change trigger, or else set up multiple watchers, one on each of the individual data items of interest. As you noted the second solution gets unwieldy very quickly.
If you can implement the required code in .Net you can get the same effect more elegantly via RegistryEvent and its subclasses.