2013-05-05 54 views
0

有人可以指点或帮助我使用Delphi XE4获取IPHONE/IPAD设备的总磁盘大小。XE4获取总磁盘大小

我只需要一个起点,我试图用:

Device : UIDevice; 

但它没有引用。

谢谢

+0

你是什么意思下 '没有参考'? – 2013-05-05 12:08:23

+0

我的意思是设备没有引用磁盘属性。 – user2240395 2013-05-05 12:11:12

+0

相关http://stackoverflow.com/questions/5712527/how-to-detect-total-available-free-disk-space-on-the-iphone-ipad-device – RRUZ 2013-05-06 01:52:38

回答

1
uses 
    iOSapi.Foundation, Macapi.ObjectiveC; 

function GetTotalDiskSize(FolderName: string): Int64; 
var 
    Dict: NSDictionary; 
    P: Pointer; 
const 
    FoundationFwk: string = '/System/Library/Frameworks/Foundation.framework/Foundation'; 
begin 
    Result := 0; 
    Dict := TNSFileManager.Wrap(TNSFileManager.OCClass.defaultManager).attributesOfFileSystemForPath(NSStr(FolderName), nil); 
    if Dict = nil then 
    Exit; 
    P := Dict.objectForKey((CocoaNSStringConst(FoundationFwk, 'NSFileSystemSize') as ILocalObject).GetObjectID); 
    if Assigned(P) then 
    Result := TNSNumber.Wrap(P).unsignedLongLongValue; 
end;