A customer had a question about the
RegNotifyChangeKeyValue
function.
We are using it to monitor the
HKEY_
tree as follows:CLASSES_ ROOT RegNotifyChangeKeyValue( HKEY_CLASSES_ROOT, true, // monitor entire subtree REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_LAST_SET, eventRegKeyChanged, true); // asynchronous modeIf I understand the documentation correctly, this registers for notifications when subkeys are added, deleted, or when values are changed. However, it seems that my event becomes signaled at many other times, for example, when I switch folders in an Explorer window. I fired up Process Monitor and confirmed that nobody (not even Explorer) is writing to
HKEY_
.CLASSES_ ROOT Why are we getting spurious notifications? Have we misunderstood what this function does?
Everything is working as expected; it's just that your expectations are wrong.
Recall that the
HKEY_
registry key
is really a
combined view of
HKEY_
and
HKEY_
.
Specifically, it is a combined view of
HKEY_
and
HKEY_
.
And
HKEY_
is itself just an alias for
HKEY_
.
Therefore, if you're going to look in
Process Monitor,
you need to be looking at all of those locations to see changes
that eventually get reported as changes in
HKEY_
.
In this particular case, Explorer was making changes to
HKEY_
,
which shows up as
HKEY_
.
Upon receiving this explanation, the customer understood what was going on, and also remarked that they were going to look to see if they could register their notification on a location that isn't quite so broad.