I’m writing some software that automatically connects a Bluetooth device using the Windows Bluetooth API. When it connects, Windows automatically starts installing the Bluetooth HID device driver, as expected:

This takes about 10-15 seconds, after which Windows displays the familar ‘ready for use’ message:

The problem is that BluetoothSetServiceState() returns as soon as the driver install begins, not when the device is actually ready for use. This causes some problems for my code, because it invokes a separate library for device communication as soon as it’s ‘connected’. The first few calls fail because the drivers haven’t finished installing, and making those connection attempts appears to interfere with the driver installation, because if I try to use the communication library before the driver installation has finished Windows wants to restart before the device can be used.
What I’m looking for is a way to hook that ‘ready to use’ event, when driver installation has actually finished, so I don’t make my communication library calls prematurely. Is there some Windows API call I can use to either register a function callback or directly polling the state of driver installation?
I’m writing this in vanilla C/C++, no .NET. Thanks for your help!
You might want to have a look at this sample code and RegisterDeviceNotification function. I’m not sure for 100%, but it seems to work if you specify correct guid for your device class.