Detecting Power State Changes By Using State and Notifications Broker
4/8/2010
Applications can use State and Notifications Broker to get notification when the state of the Bluetooth radio changes. The current state of the Bluetooth radio is stored in the Bluetooth registry value under the HKEY_LOCAL_MACHINE\System\State\Hardware key. The following table shows the possible DWORD values for Bluetooth.
DWORD Value | Description |
---|---|
0 |
Power off - Bluetooth is turned off on the device. |
1 |
Connectable - Bluetooth is turned on. The local device can initiate a connection with a peer device but the local device is not discoverable by peer devices that are within range. |
3 |
Discoverable - Bluetooth is turned on. The local device is listed, when a peer device searches for available devices within range. The peer device can pair with the local device. |
For information about changing power states programmatically, see Changing the Bluetooth Radio Mode
The following topics provide information about getting transient notifications by using State and Notifications Broker functions.
The State and Notifications Broker also provides the RegistryNotifyMsgQueue function that an application can use to get notifications using message queues.
Displaying a Status Icon on the Home Screen
Application can respond to Bluetooth power state changes by displaying the state of the Bluetooth stack on the user interface, such as an icon. To add an icon to the lower right-hand corner on the Home screen of Windows Mobile Professional and Windows Mobile Classic, use the Shell_NotifyIcon function. The pnid parameter points to the NOTIFYICONDATA structure.
Setting the uFlags member of NOTIFYICONDATA to NIF_ICON | NIF_MESSAGE enables an application to register the icon and receive events on the icon by using a custom defined Windows message.
The Tray sample in the Windows Mobile Professional SDK and Windows Mobile Standard SDK demonstrates how to place an icon on the tray on the Home page, then have it activate a popup dialog. For more information, see Tray Application.