bth_mobile_conn.h

来自「通过手机蓝牙控制个人电脑上的幻灯片的播放」· C头文件 代码 · 共 64 行

H
64
字号
#define MAX_LOADSTRING 100
#define BLUETOOTHQUERY_MAXDEVICES	32
#include <winsock2.h>
#include <Ws2bth.h>

class BTH_Mobile_Conn{
private:
	BTH_ADDR deviceAddrList[BLUETOOTHQUERY_MAXDEVICES];
	TCHAR	 deviceNameList[BLUETOOTHQUERY_MAXDEVICES][64];
	char devList [32][100];
	int intDeviceCount;
	SOCKET sockBTH;
	SOCKET ClientSocket;
	SOCKADDR_BTH SockAddrBthLocal;
	bool BluetooothIsEnabled;
	bool Disconnected;

public:
	BTH_Mobile_Conn();
	~BTH_Mobile_Conn();
	const char* toChar(const wchar_t* nString);
	void ShowMessage(const char* nTitle, const char* nInfo, ...);
	wchar_t ToWChar(const char*nInfo, ...);
	int toNativeBTHAddr(const WCHAR **pp, BTH_ADDR *pba);
	void convertCharToTCHAR(char *c, TCHAR* t);
	void convertTCHARToChar(char *c, TCHAR* t);

	int InitialiseBluetooth(void);
	void TerminateBluetooth(void);


	int InitialiseWinsock(void);
	void TerminateWinsock(void);

	char* IsDeviceVaild(int intDeviceNum);

	int InitialiseSocket(void);
	void TerminateSocket(void);

	int RegisterBTHService(void);

	char* MakeConnection(int intDeviceNum);
	int ListenMsg(void);
	int AcceptMsg(void);
	char* RecieveMsg(void); /*char* can be changed*/
	int SendMsg(char* strInput);

	char* CloseSocket(void);

	char* GetServerName(int intDeviceNum);
	int GetDeviceCount(void);

	SOCKADDR_BTH  GetLocalSocketAddress(void);
	void SetLocalSocketAddress(SOCKADDR_BTH temp);

	SOCKET GetClientSocket(void);
	void SetClientSocket(SOCKET tempClientSock);

	bool IsDisconnect(void);

	/*
	TCHAR GetDeviceNameList(void);*/
};
//#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?