Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows API: Detecting when a driver install has finished
    primarykey
    data
    text
    <p>I'm writing some software that automatically connects a Bluetooth device using the Windows <a href="http://msdn.microsoft.com/en-us/library/aa362932(VS.85).aspx" rel="nofollow noreferrer">Bluetooth API</a>. When it connects, Windows automatically starts installing the Bluetooth HID device driver, as expected:</p> <p><img src="https://i.stack.imgur.com/aZuTq.gif" alt="Installing Bluetooth HID drivers"></p> <p>This takes about 10-15 seconds, after which Windows displays the familar "ready for use" message:</p> <p><img src="https://i.stack.imgur.com/Vb5Ex.gif" alt="Hardware installed and ready for use"></p> <p>The problem is that <code>BluetoothSetServiceState()</code> returns as soon as the driver install <em>begins</em>, 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.</p> <p>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?</p> <p>I'm writing this in vanilla C/C++, no .NET. Thanks for your help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload