⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hidconf.cxx

📁 CE下基于PXA255的蓝牙驱动
💻 CXX
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// This source code is licensed under Microsoft Shared Source License
// Version 1.0 for Windows CE.
// For a copy of the license visit http://go.microsoft.com/fwlink/?LinkId=3223.
//
#include <windows.h>

#include <svsutil.hxx>

#include <bt_debug.h>
#include <bt_os.h>
#include <bt_buffer.h>
#include <bt_ddi.h>
#include <bt_api.h>

#include "../base/hidconf.h"

int GetDeviceConfig (BD_ADDR *pba, DWORD *pdwFlags, unsigned char **ppsdp, unsigned int *pcsdp) {
	*pdwFlags = 0;
	*ppsdp = NULL;
	*pcsdp = 0;

	WCHAR szKeyName[MAX_PATH];
	wsprintf (szKeyName, L"software\\microsoft\\bluetooth\\device\\hid\\%04x%08x", pba->NAP, pba->SAP);

	HKEY hk;
	if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, szKeyName, 0, KEY_READ, &hk) != ERROR_SUCCESS)
		return FALSE;

	DWORD dwType = 0;
	DWORD dw = 0;
	DWORD cb = sizeof(dw);

	DWORD dwRes = ERROR_SUCCESS;
	
	dwRes = RegQueryValueEx (hk, L"active", NULL, &dwType, (LPBYTE)&dw, &cb);
	if ((dwRes == ERROR_SUCCESS) && (dwType == REG_DWORD) && (cb == sizeof(dw)) && dw)
		*pdwFlags |= HIDCONF_FLAGS_ACTIVE;

	dwType = 0;
	dw = 0;
	cb = sizeof(dw);

	dwRes = RegQueryValueEx (hk, L"auth", NULL, &dwType, (LPBYTE)&dw, &cb);
	if ((dwRes == ERROR_SUCCESS) && (dwType == REG_DWORD) && (cb == sizeof(dw)) && dw)
		*pdwFlags |= HIDCONF_FLAGS_AUTH;

	dwType = 0;
	dw = 0;
	cb = sizeof(dw);

	dwRes = RegQueryValueEx (hk, L"encrypt", NULL, &dwType, (LPBYTE)&dw, &cb);
	if ((dwRes == ERROR_SUCCESS) && (dwType == REG_DWORD) && (cb == sizeof(dw)) && dw)
		*pdwFlags |= HIDCONF_FLAGS_ENCRYPT;

	dwType = 0;
	cb = 0;

	dwRes = RegQueryValueEx (hk, L"sdp_record", NULL, &dwType, NULL, &cb);

	if (dwRes == ERROR_SUCCESS) {
		if (*ppsdp = (unsigned char *)g_funcAlloc (cb, g_pvAllocData))
			dwRes = RegQueryValueEx (hk, L"sdp_record", NULL, &dwType, *ppsdp, &cb);
	}

	RegCloseKey (hk);

	if ((dwRes != ERROR_SUCCESS) || (! *ppsdp)) {
		*pdwFlags = 0;

		if (*ppsdp) {
			g_funcFree (*ppsdp, g_pvFreeData);
			*ppsdp = NULL;
		}

		return FALSE;
	}

	*pcsdp = cb;

	return TRUE;
}

⌨️ 快捷键说明

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