Entwickler-Ecke

Windows API - Windows Bluetooth API - Fehler 1306


Iceonly - Di 29.01.08 20:12
Titel: Windows Bluetooth API - Fehler 1306
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)



Delphi-Quelltext
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>0then 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 > 0then
   begin
          
     inc(BlueToothAdaptercount);
     findDevices(hRadio);
     while BluetoothFindNextRadio( hFind, hRadio ) do
         begin
            inc(BlueToothAdaptercount);
        
             //now scan for devices...
             findDevices(hRadio);
         end;
      BluetoothFindRadioClose( hFind );
  end else 
     showmessage('Kein Bluetooth-Adapter gefunden');
end;



Weiss jemand wo der Fehler liegt?


Delete - Mi 06.04.11 09:26

Hier ist ein funktionierendes Beispiel:
http://www.delphipraxis.net/158132-bluetooth-geraete-der-naeher-erkennen.html