Windows Mobile的蓝牙状态
来源:互联网 发布:网络西西河 编辑:程序博客网 时间:2024/05/16 06:04
蓝牙的状态有三种状态,分别为:BTH_POWER_OFF、BTH_CONNECTABLE、BTH_DISCOVERABLE。
三种状态分别是关闭蓝牙;打开蓝牙,使蓝牙可连接;打开连接,使蓝牙可连接和可发现。
获取蓝牙的状态是利用API函数BthGetMode。设置蓝牙的状态是利用API函数BthSetMode。
首先我们看一下BthGetMode
其原型为:
int BthGetMode(
DWORD* pdwMode
);
其作用为:获得蓝牙设备当前的状态模式.
返回值:如果返回ERROR_SUCCESS ,则成功,否则失败。
pdwMode
);
其作用为:获得蓝牙设备当前的状态模式.
返回值:如果返回ERROR_SUCCESS ,则成功,否则失败。
BthSetMode
其原型为:
int BthSetMode(
DWORD dwMode
);
其作用为:设置蓝牙设备的状态模式,并将它表现在控制面板上。自启或硬件插入的时候都将维持此状态模式。
返回值:如果返回ERROR_SUCCESS ,则成功,否则失败。
需要在项目属性的“链接器-输入”里设置附加项bthutil.lib
// BTSwitch.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "bthutil.h"
#include "mmsystem.h"
#include "utils.h"
// TODO: Get rid of hard coded strings
// WAV Filenames
const TCHAR* kszOffFileName = _T("//OFF.WAV");
const TCHAR* kszConnectableFileName = _T("//CONNECTABLE.WAV");
const TCHAR* kszVisibleFileName = _T("//VISIBLE.WAV");
// Command line option for Visivle Mode
const TCHAR* kszVisibleMode = _T("-v");
bool bDiscovrableMode = false; // by default only toggle between off and connectable modes
int _tmain(int argc, TCHAR* argv[])
{
DWORD dwMode;
const TCHAR* pszSound = NULL;
TCHAR pszFileName[MAX_PATH];
//check for command line parameter
bDiscovrableMode = CheckCmdLineParameter(argc, argv, kszVisibleMode, true);
// Get Current BT Mode
if (BthGetMode(&dwMode) == ERROR_SUCCESS)
{
// Toggle between Off and either Connectable or Discoverable modes acording to the bDiscovrableMode flag
if (dwMode != BTH_POWER_OFF)
{
dwMode = BTH_POWER_OFF; // curently BT is on, turn it off
}
else
{ // BT is off, turn it on
bDiscovrableMode ? dwMode = BTH_DISCOVERABLE : dwMode = BTH_CONNECTABLE;
}
// Set the new mode
if (BthSetMode(dwMode) == ERROR_SUCCESS)
{
// Play a sound with the new mode
switch (dwMode)
{
case BTH_POWER_OFF:
pszSound = kszOffFileName;
break;
case BTH_CONNECTABLE:
pszSound = kszConnectableFileName;
break;
case BTH_DISCOVERABLE:
pszSound = kszVisibleFileName;
break;
}
GetCurrentDirectory(pszFileName);
_tcscat(pszFileName, pszSound);
PlaySound (pszFileName, NULL, SND_SYNC|SND_FILENAME);
}
}
return 0;
}
- Windows Mobile的蓝牙状态
- Windows Mobile 设定TextBox的输入法状态
- 恢复windows mobile模拟器的初始状态
- Windows Mobile 5.0 蓝牙开发
- windows mobile 蓝牙点对点通信
- Windows Mobile操作蓝牙打印机
- Windows Mobile .Net CF中电话状态的捕获
- 在Windows Mobile模拟器上使用蓝牙
- Windows 10 Mobile(UWP)蓝牙开发
- 求助 蓝牙 windows mobile 2003se
- Mobile API for 蓝牙(android/IOS/windows)
- 蓝牙状态的监听
- 蓝牙的状态详解
- 蓝牙的设置状态
- 含jsr82的J2ME蓝牙程序能否在windows mobile上运行起来?
- Windows Mobile下界面自适应输入法状态
- Windows Mobile下界面自适应输入法状态
- mobile手机中蓝牙连接的区别
- #ifdef __cplusplus extern "C" { #endif 的解释
- frameset使用
- Android Power Management
- 使用python 3.0 处理utf8格式的文件BOM问题
- 得分
- Windows Mobile的蓝牙状态
- android JNI编程 一些技巧(整理)
- wait和waitpid
- Android 网站资源收集大全
- WPF拖放编程
- 什么是syslogd
- 十句表达“很简单”【转】
- 众多站长将网站移民海外 该如何选择国外VPS
- 寄存器与函数栈帧之整理篇