Bluetooth and WM_DEVICECHANGE Messages

Bluetooth includes specific WM_DEVICECHANGE messages that enable developers to obtain messages when Bluetooth devices undergo status changes. This topic describes how to receive Bluetooth-specific WM_DEVICECHANGE messages and lists Bluetooth-specific messages.

Receiving Bluetooth-specific WM_DEVICECHANGE Messages

To receive WM_DEVICECHANGE messages, a handle to the local radio must first be opened. To do this, use one of the following methods:

When the Bluetooth radio handle is opened, call the RegisterDeviceNotification function and register for notifications on the handle using DBT_DEVTYP_HANDLE as the devicetype. When registered, the following GUIDs are sent, and the DEV_BROADCAST_HANDLE::dbch_data member is the associated buffer.

Bluetooth-specific Messages

The following table lists Bluetooth-specific WM_DEVICECHANGE messages.

GUID BUFFER Description
GUID_BLUETOOTH_HCI_EVENT BTH_HCI_EVENT_INFO This message is sent when a remote Bluetooth device connects or disconnects at the ACL level.
GUID_BLUETOOTH_L2CAP_EVENT BTH_L2CAP_EVENT_INFO This message is sent when an L2CAP channel between the local radio and a remote Bluetooth device has been established or terminated. For L2CAP channels that are multiplexers, such as RFCOMM, this message is only sent when the underlying channel is established, not when each multiplexed channel, such as an RFCOMM channel, is established or terminated.
GUID_BLUETOOTH_PIN_REQUEST Not applicable. This message should be ignored by the application. If the application must receive PIN requests, the BluetoothRegisterForAuthentication function should be used.
GUID_BLUETOOTH_RADIO_IN_RANGE BTH_RADIO_IN_RANGE This message is sent when any of the following attributes of a remote Bluetooth device has changed: the device has been discovered, the class of device, name, connected state, or device remembered state. This message is also sent when these attributes are set or cleared.
GUID_BLUETOOTH_RADIO_OUT_OF_RANGE BLUETOOTH_ADDRESS This message is sent when a previously discovered device has not been found after the completion of the last inquiry. This message will not be sent for remembered devices. The BTH_ADDRESS structure is the address of the device that was not found.