Jason Marks
Jason Marks

Reputation: 21

Is there a way to turn on Bluetooth using winapi?

I'm looking for a way to turn on my computer's Bluetooth using the Windows API only. I didn't see any function in BluetoothApis.h for this. If you know any way (maybe using the Device API), I would love to hear it!

This is the setting I want to turn on using the Windows API:

image

Upvotes: 2

Views: 1767

Answers (1)

rustyx
rustyx

Reputation: 85392

I don't know about Win32 API, but it can be done easily via Windows Runtime API Windows.Devices.Radios. The RadioState enum can be set to On, Off or Disabled.

A UWP example is here.

For Win32 apps it is still possible to access the Windows Runtime API, for example by compiling with VC++ /ZM flag ("Consume Windows Runtime Extension") and invoking Windows::Foundation::Initialize(); on startup, as explained in the Microsoft's blog: How to access the Windows 10 APIs from C++.

Upvotes: 1

Related Questions