BluetoothFindFirstDevice 함수는 Bluetooth 디바이스 열거를 시작합니다.
HBLUETOOTH_DEVICE_FIND BluetoothFindFirstDevice(
const BLUETOOTH_DEVICE_SEARCH_PARAMS *pbtsp,
BLUETOOTH_DEVICE_INFO *pbtdi
);
API를 이용한 Sample Code
#include "bluetoothapis.h"
#pragma comment(lib, "Bthprops.lib")
void CBluetoothFindFirstDeviceDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST, m_listBox);
}
void CBluetoothFindFirstDeviceDlg::OnBnClickedButton1()
{
BluetoothFind();
}
int CBluetoothFindFirstDeviceDlg::BluetoothFind()
{
HBLUETOOTH_DEVICE_FIND founded_device;
BLUETOOTH_DEVICE_INFO device_info;
memset(&device_info, 0, sizeof(BLUETOOTH_DEVICE_INFO));
device_info.dwSize = sizeof(device_info);
BLUETOOTH_DEVICE_SEARCH_PARAMS search_criteria;
memset(&search_criteria, 0, sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS));
search_criteria.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS);
search_criteria.fReturnAuthenticated = FALSE;
search_criteria.fReturnRemembered = FALSE;
search_criteria.fReturnConnected = TRUE;
search_criteria.fReturnUnknown = FALSE;
search_criteria.fIssueInquiry = FALSE;
search_criteria.cTimeoutMultiplier = 0;
founded_device = BluetoothFindFirstDevice(&search_criteria, &device_info);
if (founded_device == NULL)
{
TRACE(_T("(%s)[%d] Error: %d\n"), __FUNCTIONW__, __LINE__, WSAGetLastError());
return -1;
}
do
{
m_listBox.AddString(device_info.szName);
TRACE(_T("(%s)[%d] founded device : %s\n"), __FUNCTIONW__, __LINE__,device_info.szName);
} while (BluetoothFindNextDevice(founded_device, &device_info));
return 0;
}
void CBluetoothFindFirstDeviceDlg::OnBnClickedButton2()
{
m_listBox.ResetContent();
}
'MFC' 카테고리의 다른 글
CFileDialog의 Title 이름 변경하는 방법 (0) | 2024.01.16 |
---|---|
MFC 단축키 Accelerator 리소스 추가 (0) | 2024.01.16 |
최근 열어본 파일 MRU Menu Items 처리 커스텀 방법 (1) | 2024.01.15 |
UpdateData() 함수 Param 의미 (0) | 2023.07.07 |
ON_CONTROL_RANGE를 이용해서 같은 이벤트 처리를 한 함수로 해결 방법 (0) | 2023.07.05 |