当需要注册表某项改变时通知我们,可以通过调用RegistryNotifyCallback实现,当不再需要时需要调用RegistryCloseNotification关闭通知
HREGNOTIFY g_hNotify[3];
void CloseNotificationReg(void) { RegistryCloseNotification(g_hNotify[0]); RegistryCloseNotification(g_hNotify[1]); RegistryCloseNotification(g_hNotify[2]); }
void RegCallback(HREGNOTIFY hNotify, DWORD dwUserData, const PBYTE pData, const UINT cbData) { printf("RegCallback/n"); }
void NotificationReg(void) { NOTIFICATIONCONDITION nc;
nc.ctComparisonType = REG_CT_ANYCHANGE; nc.dwMask = SN_POWERBATTERYSTATE_BITMASK; nc.TargetValue.dw = 0;
RegistryNotifyCallback( SN_MESSAGINGSMSUNREAD_ROOT, SN_MESSAGINGSMSUNREAD_PATH, SN_MESSAGINGSMSUNREAD_VALUE, RegCallback, // This notification uses a callback. 0, &nc, &g_hNotify[0] );
RegistryNotifyCallback( SN_MESSAGINGMMSUNREAD_ROOT, SN_MESSAGINGMMSUNREAD_PATH, SN_MESSAGINGMMSUNREAD_VALUE, RegCallback, // This notification uses a callback. 0, &nc, &g_hNotify[1] );
RegistryNotifyCallback( SN_PHONEMISSEDCALLS_ROOT, SN_PHONEMISSEDCALLS_PATH, SN_PHONEMISSEDCALLS_VALUE, RegCallback, // This notification uses a callback. 0, &nc, &g_hNotify[2] ); } |