Delphi XE7实现手机上获取wifi信息的程序


本文整理自网络,侵删。

 介绍

本文章介绍了Delphi XE7实现手机上获取wifi信息的程序,具体代码如下,或者直接下载附件

unit Main;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
  FMX.Layouts, FMX.Memo;

type
  TFormMain = class(TForm)
    ButtonInfo: TButton;
    Memo: TMemo;
    procedure ButtonInfoClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormMain: TFormMain;

implementation

uses Androidapi.Helpers, Androidapi.JNI.JavaTypes, Androidapi.JNIBridge,
  Androidapi.JNI.GraphicsContentViewText, android.net.wifi;

{$R *.fmx}
{$R *.NmXhdpiPh.fmx ANDROID}

procedure TFormMain.ButtonInfoClick(Sender: TObject);
var
  Service: JObject;
  WifiManager: JWifiManager;
  ConnectionInfo: JWifiInfo;
  ScanResults: JList;
  ScanResult: JScanResult;
  I: Integer;
begin
  Memo.Lines.Clear;

  Service := SharedActivity.getSystemService(TJContext.JavaClass.WIFI_SERVICE);
  WifiManager := TJWifiManager.Wrap((Service as ILocalObject).GetObjectID);
  if not WifiManager.isWifiEnabled then
    Memo.Lines.Add('Wifi is disabled')
  else
  begin
    ConnectionInfo := WifiManager.getConnectionInfo;
    Memo.Lines.Add('Connection info');
    Memo.Lines.Add('  SSID: ' + JStringToString(ConnectionInfo.getSSID));
    Memo.Lines.Add('  BSSID: ' + JStringToString(ConnectionInfo.getBSSID));
    Memo.Lines.Add('  MAC address: ' + JStringToString(ConnectionInfo.getMacAddress));
    ScanResults := WifiManager.getScanResults;
    for I := 0 to ScanResults.size - 1 do
    begin
      Memo.Lines.Add('');
      Memo.Lines.Add('Detected access point ' + IntToStr(I));
      ScanResult := TJScanResult.Wrap((ScanResults.get(I) as ILocalObject).GetObjectID);
      Memo.Lines.Add('  SSID: ' + JStringToString(ScanResult.SSID));
      Memo.Lines.Add('  BSSID: ' + JStringToString(ScanResult.BSSID));
      Memo.Lines.Add('  Capabilities: ' + JStringToString(ScanResult.capabilities));
      Memo.Lines.Add('  Frequency: ' + IntToStr(ScanResult.frequency) + 'MHz');
      Memo.Lines.Add('  Signal level: ' + IntToStr(ScanResult.level) + 'dBm');
    end
  end
end;

end.

相关阅读 >>

Delphi屏蔽指定热键

Delphi 获取外部程序句柄与发送消息

Delphi 控制台程序加图标方法

Delphi fileopendialog1 多选加载大量文件,不受中文文件名影响

Delphi用邻域平均法对图像进行平滑处理

Delphi 线程中修改主窗体的控件内容

Delphi 中文大写日期转换函数

Delphi xe8中的正则表达式提取日语(平假名,片假名,汉字)

Delphi获得硬盘所有分区

Delphi从excel读取数据存入数据库demo

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...