I want to create a simple C++ app that programmatically toggles Bluetooth. I have successfully used bluetoothapis.h
to query and list information about Bluetooth devices, but I cannot find any function that can toggle the state of it (like the WlanSetInterface
function in wlanapi.h
).
I know I can use the Radio Manager API or the SetupDi API but I have no idea how to.
I also read this question: Is there a way to turn on Bluetooth using winapi?, but still I don't know how I could do it.
Thank you for your help in advance!
There are 3 way to do what you need:
Use WinRT API Radio::SetStateAsync
.
Internally those API uses Radio Manager that can be called directly using COM API. Take a look at the IMediaRadioManager
interface. It provides access to a collection of IRadioInstance
interfaces. Its SetRadioState
method turns the corresponding Bluetooth radio on or off.
Direct call to the driver.