I'm trying to connect to a bluetooth device using the RegisterDevice function. Unfortunately no matter which port I select I always get error code 2404 ERROR_DEVICE_IN_USE. There is nothing currently connected to the Bluetooth device and no devices already registered to any com port. Has anyone had this problem before and know of a way to fix it? I've included the code snippet below.
char
*Bth::BtRegister(char *DeviceAddress)
{
char *Addr = DeviceAddress;
PORTEMUPortParams pp = {0};
TCHAR Prefix[5];
int i;
pp.channel = 1;
for (i=0; i<12; ++i, ++Addr){
int c = *Addr;
if(c >= 'a') c = c - 'a' + 0xa;
else if (c >= 'A') c = c - 'A' + 0xa;
else c = c - '0';
pp.device = pp.device * 16 + c;
}
_tcscpy(Prefix, _T(PORT_PREFIX_BT));
for(i = 0; i < 5; i++){
DWORD err;
BtHandle = RegisterDevice(&Prefix[0],
PORT_SUFFIX_BT,
L
"btd.dll",
(DWORD)&pp);
err = GetLastError();
if(BtHandle) {
strcpy(&BtPortName[0], PORT_NAME_BT);
return &BtPortName[0];
}
}
return 0;
}