HANDLE ActivateSPP(WCHAR* sz, BT_ADDR btAddr) { int index = 0; PORTEMUPortParams pp; memset(&pp, 0, sizeof(pp)); unsigned char nChannel = 0xfe; pp.channel = nChannel & 0xff; if (wcsicmp(sz, L"client") == 0) { pp.device = btAddr; pp.uiportflags = RFCOMM_PORT_FLAGS_REMOTE_DCB; } if (wcsicmp(sz, L"server") == 0) { pp.flocal = TRUE; } HANDLE hDevice = NULL; for (index = 1; index <= 9; index++) { hDevice = RegisterDevice(L"COM", index, L"btd.dll", (DWORD)&pp); if (hDevice != NULL) { break; } } WCHAR szComPort[30]; wsprintf(szComPort, L"COM%d:", index); HANDLE hCommPort = CreateFile(szComPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (hCommPort == INVALID_HANDLE_VALUE) { DeregisterDevice(hDevice); return INVALID_HANDLE_VALUE; } return hDevice; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)