Autor Beitrag
jjturbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Di 05.04.11 07:57 
Moin Forum,

ich möchte ein kleines Programm schreiben, um Bluetoothgeräte in der Nähe anzuzeigen.

Ich habe jetzt mal mit "JwaBluetoothAPIs.pas,v 1.11 2005/09/06 16:36:50 marquardt Exp $" probiert, aber mit diesem Codeschnipsel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure Finde;
var
  hFind             :HBLUETOOTH_RADIO_FIND;
  hDevFind          :HBLUETOOTH_DEVICE_FIND;
  FindParams        :BLUETOOTH_FIND_RADIO_PARAMS;
  SearchParams      :BLUETOOTH_DEVICE_SEARCH_PARAMS;
  SearchParamsSize  :dword;
  DevInfo           :^PBLUETOOTH_DEVICE_INFO;
  DevInfoSize       :dword;
  hRadio            :THandle;
  RadioInfo         :PBLUETOOTH_RADIO_INFO;
  RadioInfoSize     :dword;
begin

  RadioList.Clear;
  DeviceList.Clear;

  FindParams.dwSize := SizeOf(BLUETOOTH_FIND_RADIO_PARAMS);
  hFind             := BluetoothFindFirstRadio(@FindParams, hRadio);

  if hFind <> 0 then begin


ist hFind immer 0.

Was mache ich denn falsch?

Gruß Oliver


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Di 05.04.2011 um 10:02

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19326
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 05.04.11 10:11 
user profile iconjjturbo hat folgendes geschrieben Zum zitierten Posting springen:
Was mache ich denn falsch?
Du liest die Hilfe nicht oder hast vergessen das Ergebnis hier zu schreiben...
msdn.microsoft.com/e...362786(v=vs.85).aspx hat folgendes geschrieben:
Returns NULL upon failure. Call the GetLastError function for more information on the error.
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Di 05.04.11 15:04 
GetLasterror meldet Fehler 259, "Es sind keine Daten mehr verfügbar".

Windows.pas:
ausblenden Delphi-Quelltext
1:
2:
3:
  { No more data is available. }
  ERROR_NO_MORE_ITEMS = 259;
  {$EXTERNALSYM ERROR_NO_MORE_ITEMS}

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 05.04.11 15:21 
Mit diesem "Codeschnipsel" kann ich nichts anfangen...
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Di 05.04.11 15:23 
ausblenden volle Höhe 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:
procedure TForm1.Button1Click(Sender: TObject);
const
  BTTimeOut = 10;
var
  hFind             :HBLUETOOTH_RADIO_FIND;
  hDevFind          :HBLUETOOTH_DEVICE_FIND;
  FindParams        :BLUETOOTH_FIND_RADIO_PARAMS;
  SearchParams      :BLUETOOTH_DEVICE_SEARCH_PARAMS;
  SearchParamsSize  :dword;
  DevInfo           :^PBLUETOOTH_DEVICE_INFO;
  DevInfoSize       :dword;
  hRadio            :THandle;
  RadioInfo         :PBLUETOOTH_RADIO_INFO;
  RadioInfoSize     :dword;

  RadioList         :TStringList;
  DeviceList        :TStringList;
  ErrNo             :Integer;
  ErrText           :String;
begin

  RadioList  := TStringList.Create;
  DeviceList := TStringList.Create;


  protokoll(clBlack,'Suche nach BT-Sendern...');
  RadioList.Clear;
  DeviceList.Clear;

  FindParams.dwSize := SizeOf(BLUETOOTH_FIND_RADIO_PARAMS);
  hFind             := BluetoothFindFirstRadio(@FindParams, hRadio);

  if hFind = 0 then begin
    ErrNo := GetLastError;  <--Fehler 259---------------------------------------------------------
    Showmessage('GetLastError meldet Fehlernr. ' + IntToStr(ErrNo) + ': ' + SysErrorMessage(ErrNo));
  end;

  if hFind <> 0 then begin

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
ALF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: Di 05.04.11 15:40 
Wie währe es wenn Du noch auf das Timeout wartest! So schnell ist der Scann nicht!

Gruss Alf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Mi 06.04.11 07:05 
Wieso Scan? BluetoothFindFirstRadio sucht doch erst mal nur nach einem Bluetoothsender im PC, oder?

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
ALF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: Mi 06.04.11 10:07 
oops sorry! ist Dein Device denn im /am PC Aktiv? Da man es ja auch deaktivieren kann wenn man es nicht brauch.

Und schau mal hier. Vielleicht hilft es Dir.

Gruss ALf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Mi 06.04.11 10:13 
Ok, danke für den Link.
Ich habe schon mehrere Varianten, die ich woanders gefunden habe ausprobiert.
BluetoothFindFirstRadio findet nichts.
Eingeschaltet ist es natürlich, ich nutze es z.B. für Skypegespräche via Bluetootheadset.

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
ALF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: Mi 06.04.11 11:08 
Mir war aber so, als hätt ich mal gelesen das ein USB-Bluetooth auch wenn es schon Aktiv ist, der Zugriff auf die Schnittstelle unter Umständen anders reagiert als eine Onboardschnittstelle. Daher die Frage nach timeout. Kann mich natürlich jetzt auch irren :gruebel:

Alf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!