Windows API: detection after driver installation is complete

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:

Installing Bluetooth HID drivers

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

Hardware installed and ready for use

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!

+4
source share
3 answers

Perhaps you should take a look at this sample code and the RegisterDeviceNotification function . I'm not 100% sure, but it seems to work if you provide the right guide for your device class.

+4
source

Here is what I would do:

I would like to describe in more detail at # 4, but I am not familiar with the specific message of the window that you need. Look here for possible expected messages in the window .

However, as soon as you determine the correct window message to search for, then programmatically your program waits (and processes) this WM. CodeProject has a great entry on how to do this in C ++ . Personally, I would rather do it in Delphi .

+2
source

If it is a network binding, then RNDIS sends a message when it completes the installation in accordance with the RNDIS Driver Implementation Guide and RNDIS Definition

or

You can install or query the list of devices programmatically through the Devcon utility (source code is available from MSDN), as indicated in the Examples

0
source

All Articles