Ver Mensaje Individual
  #14  
Antiguo 28-09-2023
jhonalone jhonalone is offline
Miembro
 
Registrado: sep 2007
Ubicación: Madrid
Posts: 547
Reputación: 17
jhonalone Va por buen camino
Hola, Dani.
No estoy familiarizado con los hilos TThread.
Intentaré implementarlo y te contaré.
Si me veo obligado y no soy capaz, te rogaría que me ayudaras implementándolo en el procedimiento que me originó el problema y yo ya lo trasladaría a otros problemas similales. Gracias.
Código Delphi [-]
procedure TDevice.ListaDevices;
var
  Msg: string;
  I, B: Integer;

  ListaVinculados: TBluetoothDeviceList;
  LServices: TBluetoothServiceList;
begin

  try

    FBluetoothManager := TBluetoothManager.Current;
    if FBluetoothManager = nil
    then begin
         Close;
         end;

    FBluetoothManager.SocketTimeout := 100;

    BluetoothAdapter := FBluetoothManager.CurrentAdapter;

    if BluetoothAdapter = nil
    then begin
         Close;
         end;

    ListaVinculados := FBluetoothManager.GetPairedDevices(BluetoothAdapter);
    if ListaVinculados = nil
    then begin
         Close;
         end;

   ComboDevices.Items.Clear; // Limpiamos cada vez el combo

    for I := 0 to ListaVinculados.Count - 1 do
    begin
      Impresora := ListaVinculados[i] as TBluetoothDevice;
      if Impresora.IsPaired then
      begin
        LServices := Impresora.GetServices;
        for B := 0 to LServices.Count - 1 do
        begin
          ServiceGUI := GUIDToString(LServices[b].UUID);
          Guid := LServices[b].UUID;
          ServiceName := LServices[b].Name;
        end;
      end
      else begin
           Close;
           end;
    ComboDevices.Items.Add(Impresora.DeviceName);
    end;
  except
   on E: Exception do
   begin
     Close;
   end;

 end;
 FBluetoothManager.Free;
 BluetoothAdapter.Free;
 Guid.Empty;
 if ComboDevices.Items.Count > 0 // Seleccionamos el primero
   then ComboDevices.ItemIndex := 0;

end;
Un saludo muy efusivo.
__________________
"Pedid y se os dará; buscad y hallaréis ..." (Lc 11,9-10)
"...si no tengo caridad, nada soy..." (1 Cor 13,1-13)
Responder Con Cita