如题
解决方案 »
- 乱了,compress、gzip、inflate到底是不是一种格式啊?
- 如何实现双缓冲?
- 为什么在DEUBG下AfxMessageBox出来,在release下就不出来
- 小妹请问各位大虾有关QQ的开发问题
- socket阻塞了还有响应吗?
- WIN会自动用记事本打开这个文件
- 关于关系表达式的问题!
- listview设置背景图片、设置背景色的代码,要的来报名
- 请问如何得到文件的当前状态
- how to dynamicly disable a control(such as ccombobox or edit box)
- ......请问一个SDI应用程序,它的每一个子窗口都有菜单、工具条,也即子窗口和SDI主窗口差不多,怎样实现?......
- 发布软件到哪些网站效果好些?
regsnap 可以对比的,,
Platform SDK: Windows System Information
RegNotifyChangeKeyValueThe RegNotifyChangeKeyValue function notifies the caller about changes to the attributes or contents of a specified registry key.
LONG RegNotifyChangeKeyValue(
HKEY hKey,
BOOL bWatchSubtree,
DWORD dwNotifyFilter,
HANDLE hEvent,
BOOL fAsynchronous
);
Parameters
hKey
[in] Handle to an open key. This handle is returned by the RegCreateKeyEx or RegOpenKeyEx function, or it can be one of the following predefined keys: HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
The key must have been opened with the KEY_NOTIFY access right. For more information, see Registry Key Security and Access Rights.bWatchSubtree
[in] If this parameter is TRUE, the function reports changes in the specified key and its subkeys. If the parameter is FALSE, the function reports changes only in the specified key.
dwNotifyFilter
[in] Changes that should be reported. This parameter can be one or more of the following values. Value Meaning
REG_NOTIFY_CHANGE_NAME
0x00000001L Notify the caller if a subkey is added or deleted.
REG_NOTIFY_CHANGE_ATTRIBUTES
0x00000002L Notify the caller of changes to the attributes of the key, such as the security descriptor information.
REG_NOTIFY_CHANGE_LAST_SET
0x00000004L 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
0x00000008L Notify the caller of changes to the security descriptor of the key. hEvent
[in] 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, hEvent is ignored.
fAsynchronous
[in] If this parameter is TRUE, the function returns immediately and reports changes by signaling the specified event. If 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 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 with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.Res
This function cannot be used to detect changes to the registry that result from using the RegRestoreKey function.If 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.If the thread that called RegNotifyChangeKeyValue exits, the event is signaled. When the event is signaled, RegNotifyChangeKeyValue ends its monitoring of the key value. If you want to monitor further changes in the value of the key, call RegNotifyChangeKeyValue again.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.If this function is called more than once with different values for the bWatchSubtree and dwNotifyFilter parameters, the changed parameter values will be ignored on subsequent calls. If you want to call RegNotifyChangeKeyValue again with different values for these parameters, you must first close the key handle hKey by calling RegCloseKey, then reopen the key handle by calling RegOpenKeyEx.Example Code [C++]
The following program illustrates how to use RegNotifyChangeKeyValue.#include <stdio.h>
#include <windows.h>void main(int argc, char *argv[])
{
DWORD dwFilter = REG_NOTIFY_CHANGE_NAME |
REG_NOTIFY_CHANGE_ATTRIBUTES |
REG_NOTIFY_CHANGE_LAST_SET |
REG_NOTIFY_CHANGE_SECURITY; HANDLE hEvent;
HKEY hMainKey;
HKEY hKey;
LONG lErrorCode; // Display the usage error message.
if (argc != 3)
{
printf("Usage: notify [HKLM/HKU/HKCU/HKCR/HCC] [subkey]\n");
return;
} // Convert parameters to appropriate handles.
if (strcmp("HKLM", argv[1]) == 0) hMainKey=HKEY_LOCAL_MACHINE;
else if(strcmp("HKU", argv[1]) == 0) hMainKey=HKEY_USERS;
else if(strcmp("HKCU", argv[1]) == 0) hMainKey=HKEY_CURRENT_USER;
else if(strcmp("HKCR", argv[1]) == 0) hMainKey=HKEY_CLASSES_ROOT;
else if(strcmp("HCC", argv[1]) == 0) hMainKey=HKEY_CURRENT_CONFIG;
else
{
printf("Usage: notify [HKLM/HKU/HKCU/HKCR/HCC] [subkey]\n");
return;
} // Open a key.
lErrorCode = RegOpenKeyEx(hMainKey, argv[2], 0, KEY_NOTIFY, &hKey);
if (lErrorCode != ERROR_SUCCESS)
{
printf("Error in RegOpenKeyEx.\n");
return;
} // Create an event.
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (hEvent == NULL)
{
printf("Error in CreateEvent.\n");
return;
} // Watch the registry key for a change of value.
lErrorCode = RegNotifyChangeKeyValue(hKey,
TRUE,
dwFilter,
hEvent,
TRUE);
if (lErrorCode != ERROR_SUCCESS)
{
printf("Error in RegNotifyChangeKeyValue.\n");
return;
} // Wait for an event to occur.
if (WaitForSingleObject(hEvent, INFINITE) == WAIT_FAILED)
{
printf("Error in WaitForSingleObject.\n");
return;
} // Close the key.
lErrorCode = RegCloseKey(hKey);
if (lErrorCode != ERROR_SUCCESS)
{
printf("Error in RegCloseKey.\n");
return;
}
// Close the handle.
if (!CloseHandle(hEvent))
{
printf("Error in CloseHandle.\n");
return;
}
}Requirements
Client Requires Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, or Windows 98.
Server Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header Declared in Winreg.h; include Windows.h.
Library Link to Advapi32.lib.
DLL Requires Advapi32.dll. See Also
Registry Functions, RegCloseKey, RegDeleteKey, RegEnumKeyEx, RegEnumValue, RegQueryInfoKey, RegQueryValueEx
--------------------------------------------------------------------------------
Last updated: March 2005 | What did you think of this topic? | Order a Platform SDK CD
© Microsoft Corporation. All rights reserved. Terms of use. Language
C++Show All
Requirements
Client Requires Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, or Windows 98.
Server Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header Declared in Winreg.h; include Windows.h.
Library Link to Advapi32.lib.
DLL Requires Advapi32.dll.
See Also
Registry Functions, RegCloseKey, RegDeleteKey, RegEnumKeyEx, RegEnumValue, RegQueryInfoKey, RegQueryValueEx