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

This takes about 10-15 seconds, after which Windows displays the familiar "ready to use" message:

The problem is that BluetoothSetServiceState() returns as soon as the driver installation begins, and not when the device is really ready to use. This causes some problems for my code because it calls a separate library to communicate with the device as soon as it "connects". The first few calls fail because the drivers did not complete the installation, and attempts of these attempts interfere with the driver installation, because if I try to use the communication library before the driver installation is complete, Windows wants to restart before the device can.
What I'm looking for is a way to bind this โready to useโ event when the driver installation is really complete, so I am not making my calls to the message library prematurely. Is there any Windows API call that I can use to register a callback function or directly query the driver installation status?
I write this in vanilla C / C ++, not .NET. Thank you for your help!
source share