接續 How to get local BT address base on WINCE5
用網路上說的 strBTAddr.Format("%I64U", _btAddr);
Debug出現 error Dialog
Assertion Failed! BluetoothAtpClient: File strex.cpp, Line 702
Release不會
但也沒有成功轉換
所以自己寫的轉換的 code
讓我可以把BT_ADDR (取得local BT address) 轉成 CString
CString strBTAddr = "none";
BYTE _byteBtAddr[6];
memset(_byteBtAddr, 0, sizeof(BYTE)*6);
_byteBtAddr[5] = _btAddr & 0xFF;
_byteBtAddr[4] = (_btAddr >> 8*sizeof(BYTE)) & 0xFF;
_byteBtAddr[3] = (_btAddr >> 2*8*sizeof(BYTE)) & 0xFF;
_byteBtAddr[2] = (_btAddr >> 3*8*sizeof(BYTE)) & 0xFF;
_byteBtAddr[1] = (_btAddr >> 4*8*sizeof(BYTE)) & 0xFF;
_byteBtAddr[0] = (_btAddr >> 5*8*sizeof(BYTE)) & 0xFF;
_byteBtAddr的陣列 就是 Bt Address
為了顯示好看
CString strBTAddr = "none";
BYTE _byteBtAddr[12];
memset(_byteBtAddr, 0, sizeof(BYTE)*12);
for(byte count=0 ; count<12>> ((12-1)-count)*4*sizeof(BYTE)) & 0xF;
}
strBTAddr.Format(_T("%x%x:%x%x:%x%x:%x%x:%x%x:%x%x"),_byteBtAddr[0],_byteBtAddr[1],_byteBtAddr[2],
_byteBtAddr[3],_byteBtAddr[4],_byteBtAddr[5],_byteBtAddr[6],_byteBtAddr[7],
_byteBtAddr[8],_byteBtAddr[9],_byteBtAddr[10],_byteBtAddr[11]);
沒有留言:
張貼留言