The API examples and documentation in earlier sections all present the Registry API in its native C/C++ form. Since many administrators are comfortable with C and/or C++, I’ll start the programming examples by presenting three distinct uses for the Registry API routines I’ve already presented.
a little-used, but very useful,
routine. It’s only present in Windows 2000 and NT, which
perhaps accounts for its relative anonymity. If you need to be
notified when a key or its values changes, it’s the best tool
for getting you that notification.
in Example 8-4, is a small utility that takes
RegNotifyChangeKeyValue to warn you
when a key you specify has been changed.
After a check of its initial command-line arguments, the code performs the following steps:
It identifies which root key “owns” the key you want to
monitor; this is required because
needs an already open key (i.e., one of the roots) to open the target
key. If it can’t figure out which root the user specified, it
prints an error and exits.
It captures the pathname of the key to monitor and uses it, along
with the root key, to call
RegOpenKeyEx. The key
is opened with
KEY_READ access, which includes
KEY_NOTIFY access too. If the key can’t be
opened, the code generates an error message and exits.
The target key is monitored with a call to
RegNotifyChangeKeyValue. The code passes ...