procedure TForm1.Button3Click(Sender: TObject);
var
hRadio,hDeviceFind:THANDLE;
hfind:HBLUETOOTH_RADIO_FIND;
btfrp:TBlueToothFindRadioParams;
radioInfo:BLUETOOTH_RADIO_INFO;
deviceInfo:BLUETOOTH_DEVICE_INFO;
deviceSearchParams:BLUETOOTH_DEVICE_SEARCH_PARAMS;
Err:integer;
begin
try try
btfrp.dwSize:=sizeof(btfrp);
hFind := BluetoothFindFirstRadio( @btfrp, hRadio );
if (hFind > 0)
then begin
repeat
radioInfo.dwSize:= sizeof(radioInfo);
if (ERROR_SUCCESS = BluetoothGetRadioInfo(hRadio, radioInfo))
then
showmessage('
Radio: '+ radioInfo.szName)
else
showmessage('
error');
deviceInfo.dwSize := sizeof(deviceInfo);
deviceSearchParams.dwSize := sizeof(deviceSearchParams);
deviceSearchParams.fReturnRemembered := true;
deviceSearchParams.hRadio := hRadio;
hDeviceFind := BluetoothFindFirstDevice(deviceSearchParams, deviceInfo);
if (hDeviceFind>0)
then begin
while(BluetoothFindNextDevice(hDeviceFind, deviceInfo))
do begin
showmessage('
Device: '+deviceInfo.szName);
end;
BluetoothFindDeviceClose(hDeviceFind);
end;
BluetoothGetDeviceInfo(hRadio, deviceInfo);
showmessage('
Device: '+deviceInfo.szName);
end;
until (BluetoothFindNextRadio( hFind, hRadio ) );
BluetoothFindRadioClose( hFind );
end else begin
Err:=GetLastError;
showmessage(SysErrorMessage(Err)+'
('+inttostr(Err)+'
)');
end;
except
on E:
Exception do begin
showmessage('
error'+e.
Message);readln;
end;
end;
finally
//readln;
end;
end;