function GetNetworkState: string; // 得到当前网络连接状态
var
NS: TNetworkState;
begin
NS := TNetworkState.Create;
try
if not NS.IsConnected then // 无网络
result := ‘0‘
else if NS.IsWifiConnected then // wifi
result := ‘1‘
else if NS.IsMobileConnected then // 移动数据
result := ‘2‘;
finally
NS.Free;
end;
end;