是否有API来启用/在Windows 8.1中禁用蓝牙? [英] Are there APIs to enable/disable Bluetooth on Windows 8.1?

查看:495
本文介绍了是否有API来启用/在Windows 8.1中禁用蓝牙?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows 8 / 8.1它现在可以启用/通过操作系统本身禁用蓝牙(见下图)。这是真棒,因为它的设备/驱动器无关。

In Windows 8/8.1 it's now possible to enable/disable Bluetooth via the OS itself (see image below). This is awesome because it's device/driver-agnostic.

在Android上,这是有可能通过 BluetoothAdapter.enable () BluetoothAdapter.disable(),但我一直没能找到什么做到这一点在Windows上(尽管看起来它是绝对有可能)。

On Android, this is possible via BluetoothAdapter.enable() and BluetoothAdapter.disable(), but I haven't been able to find anything to do this on Windows (even though it seems like it's definitely possible).

所以,我已经尝试使用:

So I've tried using:


  • BluetoothEnableIncomingConnections() - 不过,这仅prevents新传入的连接。它不会禁用现有的。

  • Devcon.exe的 - 这种方法的问题是答:它是一个非可再发行的二进制B.它需要你提前知道的时候,他的设备ID(所以它不是设备/驱动器无关)。此外,虽然它不是一个因素在于,它会是不错的的的需要提升。

  • UI自动化 - 只需启动PC设置应用程序和键盘事件切换开关很容易,但它的超级难看,无论是在适当的编码实践方面和用户体验方面。话虽这么说,这是我发现,实现我要找迄今行为的唯一途径。

  • BluetoothEnableIncomingConnections() - However, this only prevents new incoming connections. It doesn't disable existing ones.
  • devcon.exe - The problem with this method is that A. it is a non-redistributable binary B. it requires that you know he device ID ahead of time (so it's not device/driver-agnostic). Also, while it's not a dealbreaker, it'd be nice to not require elevation.
  • UI Automation - Simply launching the PC Settings app and toggling the switch with keyboard events is easy, but it's super ugly, both in terms of proper coding practices and in terms of user experience. That being said, this is the only way I've found to achieve the behavior I'm looking for so far.

我在C ++编写本机Win32应用程序,所以我不受限于任何Windows商店应用的要求,虽然,这将是巨大的,如果有未需要提升的方法。

I'm writing a native Win32 app in C++, so I'm not constrained to any Windows Store app requirements, although, it would be great if there was an approach that didn't require elevation.

TL; DR

是否有任何的API,WMI接口,或任何其他可用于实现等同功能的结果翻转蓝牙拨动开关?如果不是,是否有其产生相似的结果任何其他的方法呢?

Are there any APIs, WMI interfaces, or anything else available to achieve functionally equivalent results to flipping the Bluetooth toggle switch? If not, are there any alternative methods which yield similar results?

推荐答案

在win8.1你应该能够调用 BluetoothEnableRadio 启用/禁用本地电台。

In win8.1 you should be able to call BluetoothEnableRadio to enable/disable the local radio.

基本上各厂家应该包括一个方法来做到这一点,所以你不必加载DLL。

Basically the manufacturers should include a method to accomplish this so you don't have to load a dll.

与Windows 8.1的厂商开始不再需要实现无线开/关功能(蓝牙4.0收音机)作为本主题中描述的软件DLL,因为操作系统现在可以处理这个功能。的Windows 8.1将忽略任何这样的DLL,即使present。

看看这个链接,谈论它:
http://msdn.microsoft.com/en-us/library/windows/hardware/hh450832%28v=vs.85%29.aspx

check out this link which talks about it: http://msdn.microsoft.com/en-us/library/windows/hardware/hh450832%28v=vs.85%29.aspx

这篇关于是否有API来启用/在Windows 8.1中禁用蓝牙?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆