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 deleted.LONG RegNotifyChangeKeyValue(    HKEY hKey, // handle of key to watch 
    BOOL bWatchSubtree, // flag for subkey notification 
    DWORD dwNotifyFilter, // changes to be reported 
    HANDLE hEvent, // handle of signaled event 
    BOOL fAsynchronous  // flag for asynchronous reporting  
   );
 ParametershKeyIdentifies a currently open key or any of the following predefined reserved handle values: HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERSbWatchSubtreeSpecifies a flag that indicates whether 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. dwNotifyFilterSpecifies a set of flags that control which changes should be reported. This parameter can be a combination of the following values: Value Meaning
REG_NOTIFY_CHANGE_NAME Notify the caller if a subkey is added or deleted.
REG_NOTIFY_CHANGE_ATTRIBUTES Notify the caller of changes to the attributes of the key, such as 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. 
 hEventIdentifies an event. If the fAsynchronous parameter is TRUE, the function returns immediately and changes are reported by signaling this event. If fAsynchronous is FALSE, hEvent is ignored. fAsynchronousSpecifies a flag that indicates 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 cannot be TRUE.  Return ValuesIf 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 with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.ResIf the key identified by the hKey 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 hKey value that is a remote handle, it returns ERROR_INVALID_HANDLE. 

解决方案 »

  1.   

    to nowcan and lhxx:
    thank you!!
    I will try your mothed tomorrow.if it work indeed i will take my promise!
    thank you once more!!
      

  2.   

    sorry! can you help me once more?
    my problem is when my proc come into the RegNotifyChangeKeyValue() function my proc will wait for the notify,but if I want quit my proc what can I do ?
    To terminateThread? I think do this will bring up leak of memory.
    What can I do ?Who can tell me?
      

  3.   

    可用IntstallShield中的RegDBSetKeyValueEx()简单设置。
      

  4.   

    好象regmon可以抓到所有修改注册表的API,是不是一定得那么做,可是我还不会抓紧API,我也没有学过32位汇编.如果只有这样做的话,哪位大侠能告诉小弟该如何入门,有哪些好一点的参考书?