Home > Software engineering >  VB can monitor the registry?
VB can monitor the registry?

Time:10-12

As title, VB to monitor the registry needs what code?

CodePudding user response:

RegNotifyChangeKeyValue
The RegNotifyChangeKeyValue function notifies The caller about changes to The attributes or contents of a specified registry key. Note that The function does not notify The caller if The specified key is does.

LONG RegNotifyChangeKeyValue (
Hkeys hkeys,//handle to the key to watch
BOOL bWatchSubtree,//flag for subkey notification
DWORD dwNotifyFilter,//changes to be reported
HANDLE hEvent,//HANDLE to signaled the event
BOOL fAsynchronous//flag for asynchronous reporting
);

The Parameters
Hkeys
Handle to a currently open the key or any of the following predefined reserved Handle values:
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS

BWatchSubtree
Specifies a flag that are been to report changes in the specified key and all of its subkeys or only in the specified key. If this parameter is TRUE, the function reports changes in the key and its subkeys. If the parameter is FALSE, the function reports changes only in the key.
DwNotifyFilter
Specifies a set of flags that control which changes should be reported. This parameter can be a combination of the following values: Value a fancy
REG_NOTIFY_CHANGE_NAME Notify the caller if a subkey is added or does.
REG_NOTIFY_CHANGE_ATTRIBUTES Notify the caller of changes to the attributes of the key, as to the security descriptor information.
REG_NOTIFY_CHANGE_LAST_SET Notify the caller of changes to a value of the key. This can include adding or deleting a value, or changing an existing value.
REG_NOTIFY_CHANGE_SECURITY Notify the caller of changes to the security descriptor of the key.


HEvent
Handle to an event. If the fAsynchronous parameter is TRUE, the function returns immediately and changes are reported by signaling this event. If fAsynchronous is FALSE, the hEvent is ignored.
FAsynchronous
Specifies a flag that are how the function reports changes. If this parameter is TRUE, the function returns immediately and reports changes by signaling the specified event. When this parameter is FALSE, the function does not return until a change has occurred.
If hEvent does not specify a valid event, the fAsynchronous parameter always be TRUE.

The Return Values
If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is a nonzero error code defined in WINERROR. H. You can use the FormatMessage function have the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

Few
If the key identified by the hkeys parameter is closed, the event is signaled. This means that an application should not depend on the key being open after returning from a wait operation on the event.

RegNotifyChangeKeyValue does not work with remote handles. If RegNotifyChangeKeyValue is called with an hkeys value that is a remote handle, it returns ERROR_INVALID_HANDLE.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 98 or later.
Windows CE: Unsupported.
Header: Declared in winreg. H.
The Import Library: Use advapi32. Lib.

See Also
Registry the Overview, Registry Functions provides, RegDeleteKey RegEnumKey, RegEnumKeyEx, RegEnumValue, RegQueryInfoKey, RegQueryValue, RegQueryValueEx


  •  Tags:  
  • API
  • Related