top / index / prev / next / target / source
日記形式でつづる いがぴょんコラム ウェブページです。
Delphi で iOS や Android 端末の BluetoothLE アダプターが ON かどうか確認するコード。
uses System.Bluetooth;
function IsBluetoothLEAdapterEnabled: Boolean;
var
manager: TBluetoothLEManager;
adapt: TBluetoothLEAdapter;
begin
Result := False;
try
manager := TBluetoothLEManager.CreateInstance;
except
exit;
end;
try
adapt := manager.CurrentAdapter;
except
exit;
end;
try
if adapt.State = TBluetoothAdapterState.On then
begin
// BluetoothLE Adapter was found
Result := True;
exit;
end;
except
exit;
end;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
if IsBluetoothLEAdapterEnabled then
ShowMessage('BluetoothLE ON')
else
ShowMessage('BluetoothLE OFF');
end;