Windows Mobile 6.5 Registry Notification APIs
In Windows Mobile 6.5, monitoring system configuration and state updates without polling was critical for maintaining battery life and system performance. Developers utilized two primary sets of APIs to detect registry-driven configuration changes: the State and Notification Broker (SNAPI) and the low-level Windows CE registry notification functions. This article details these specific APIs, how they operated, and their implementation for tracking system and configuration events.
The State and Notification Broker (SNAPI)
The State and Notification Broker was the preferred, high-level
architecture in Windows Mobile 6.5 for monitoring device configuration,
hardware state, and application settings. It abstracted underlying
registry locations—principally within
HKEY_LOCAL_MACHINE\System\State—and allowed software to
subscribe to changes.
SNAPI provided three primary notification methods through its C/C++
API defined in snapi.h:
RegistryNotifyCallback: Registers an asynchronous callback function that executes whenever a target registry key or value changes. This was suitable for active foreground applications requiring immediate handling in memory.RegistryNotifyWindow: Directs the operating system to send a specific Windows message (such as a customWM_USERmessage) to an application's message loop (HWND) upon a registry value update.RegistryNotifyApp: Allows non-running applications to be launched by the OS when a specific registry configuration changes. The system uses a notification event to invoke an executable or wake up a background service.RegistryCloseNotification: Unregisters the notification handle to free system resources once monitoring is no longer required.
SNAPI supported filtering options via the
NOTIFICATION_CONDITION structure, enabling applications to
trigger notifications only when a value changed significantly (such as
transitioning between specific bitmasks, strings, or numeric
thresholds).
Windows CE File and Registry Change Notifications
Beneath SNAPI, Windows Mobile 6.5 relied on the Windows CE kernel (version 5.2) notification engine. For direct monitoring of registry keys outside the managed state repository, developers used native Windows CE registry change functions:
CeFindFirstRegChange: Initiates monitoring of a specified registry key and returns an event handle. The function allows the caller to monitor either an isolated key or an entire branch recursively by specifyingbWatchSubtree. It also lets software track specific change filters, such as key creations, deletions, or value modifications.CeFindNextRegChange: Resets the change notification handle, signaling that the application is ready to listen for the next registry event.CeFindCloseRegChange: Closes the notification handle when tracking is complete.
Applications integrated these functions with synchronization
primitives like WaitForSingleObject or
WaitForMultipleObjects. When the watched registry key was
modified, the kernel signaled the handle, allowing the thread to wake
up, execute necessary updates, and call CeFindNextRegChange
to resume listening.