3

I am working on developing a wrapper class to monitor changes to a particular reg value.

I am using RegNotifyChangeKeyValue so whenever any value inside regKey "Software\Bla" updated, it fires an event.

But i have multiple values inside "Software\Bla", so how can i monitor changes to single value and not all ?

User123456
  • 179
  • 1
  • 5
  • 14
  • This function was written so it could be implemented efficiently, not to do what you want to do. It doesn't "fire" an event, it signals the event. You do not know for which value, you can't know how many values changed and you can't get a notification after the event was signaled. – Hans Passant Oct 25 '16 at 07:30
  • [Example RegistryMonitor](https://dotblogs.com.tw/eaglewolf/2013/07/24/112158) – GooliveR Jun 28 '17 at 14:29

1 Answers1

1

RegNotifyChangeKeyValue will not allow to do that. It will return (or fire an event, if you are using it asynchronously) on any key/subtree change that will satisfy its filter parameter. You could either reread all values to see what exactly have changed, or use WMI registry watcher instead of RegNotifyChangeKeyValue. See references below for the additional information.

1. MSDN - Registry class

2. C# registry watcher

3. MSDN - Receiving WMI Event

4. CSMonitorRegistryChange sample code

Community
  • 1
  • 1
Ari0nhh
  • 5,720
  • 3
  • 28
  • 33
  • Thanks, My code is for windows xp & RegistryWatcher with WMI query returns Invalid class. Thanks :) – User123456 Oct 27 '16 at 06:54
  • `RegistryValueChange` class is supported in Vista and greater. It seems, that rereading values to see what has changed is your only approach. – Ari0nhh Oct 27 '16 at 06:57