Ich versuche mich gerade an der Windows Bluetooth API.
Leider erhalte ich von der BluetoothFindFirstDevice immer den Fehler 1306 (laut der Doku der JwaBluetoothAPIs.pas bedeutet dass, das das hRadio-Handle die falsche Größe hat)
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58:
| procedure findDevices(hRadio : THandle); var hDeviceFind : HBLUETOOTH_DEVICE_FIND ; deviceInfo:BLUETOOTH_DEVICE_INFO; deviceSearchParams:BLUETOOTH_DEVICE_SEARCH_PARAMS; lpMsgBuf : pchar; begin deviceInfo.dwSize := sizeof(deviceInfo);
deviceSearchParams.dwSize := sizeof(deviceSearchParams); deviceSearchParams.fReturnRemembered := true; deviceSearchParams.hRadio := hRadio;
hDeviceFind := BluetoothFindFirstDevice(deviceSearchParams, deviceInfo); if (hDeviceFind>0) then begin showmessage('Device: '+deviceInfo.szName); while(BluetoothFindNextDevice(hDeviceFind, deviceInfo)) do begin showmessage('Device: '+deviceInfo.szName); end; BluetoothFindDeviceClose(hDeviceFind); end else begin showerror('No Bluetooth device found!'+#13#10+inttostr(getlasterror)); end;
end;
procedure startScan; var hRadio : THANDLE ; hFind : HBLUETOOTH_RADIO_FIND; btfrp:TBlueToothFindRadioParams; BlueToothAdaptercount:integer; begin
BlueToothAdaptercount:=0; btfrp.dwSize:=sizeof(btfrp);
hFind := BluetoothFindFirstRadio( @btfrp, hRadio ); if (hFind > 0) then begin inc(BlueToothAdaptercount); findDevices(hRadio); while BluetoothFindNextRadio( hFind, hRadio ) do begin inc(BlueToothAdaptercount); findDevices(hRadio); end; BluetoothFindRadioClose( hFind ); end else showmessage('Kein Bluetooth-Adapter gefunden'); end; |
Weiss jemand wo der Fehler liegt?