uniGUI获取设备信息

有时候我们需要知道客户是使用什么设备登录的系统,在uniGUI中可以通过UniApplication.UniPlatform来获取。

简单记录一下,uniGUI的资料不太多,需要深入了解的,请多看DEMO。

详细使用请参考Demo:
目录:uniGUI\Demos\Touch\Detect Platform

以下是主要代码

type
  TUniPlatforms = set of TUniPlatform;
//定义一个变量
uPlat: TUniPlatforms;

uPlat := UniApplication.UniPlatform;  //获取设备信息  可以放在在页面(窗体)时

//设备类型
function DetectDeviceType: string;
begin
  if (upPhone in uPlat) then
     Result := '手机'
  else if (upTablet in uPlat) then
    result := '平板'
  else if (upDesktop in uPlat) then
    result := '电脑';
end;

function DetectModel: string;
begin
  if (upiPad in uPlat) then
    Result := 'iPad'
  else if (upiPod in uPlat) then
    Result := 'iPod'
  else if (upiPhone in uPlat) then
    Result := 'iPhone'
  else if (upAndroid in uPlat) then
    Result := 'Android Mobile Device'
  else if (upDesktop in uPlat) then
    Result := 'Desktop PC';
end;

function DetectOperationSystem: string;
begin
  if (upAndroid in uPlat) then
    Result := 'Android'
  else if (upiOS in uPlat) then
    Result := 'iOS'
  else if (upDesktop in uPlat) then
    Result := 'Desktop OS';
end;

function DetectPlatform: string;
begin
  if (upDesktop in uPlat) then
    result := 'Desktop'
  else if (upMobile in uPlat) then
    result := 'Mobile';
end;

直接调用对应的函数,就可以知道具体的设备信息了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值