有时候我们需要知道客户是使用什么设备登录的系统,在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;
直接调用对应的函数,就可以知道具体的设备信息了。