×
Namespaces

Variants
Actions

检测全部可用内存

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

平台安全性
能力: Self-Signed

文章
翻译:
hoolee
最后由 hamishwillee 在 22 Dec 2011 编辑
  • 简介

下列代码可以自签名执行,演示了如何检测可用内存

  • 用例

某些情况下,程序可能需要知道当前可用的内存,以便处理某些操作

  • 源码
//necessary library
LIBRARY efsrv.lib
//necessary header file
#include <f32file.h>
 
RFs fileSession;
TVolumeInfo volumeInfo;
 
//open RFs session
fileSession.Connect();
 
//freeMemory will store number of free memory in Bytes
TBuf<64> freeMemory;
TInt64 freeKBytes;
//Contains drive information.
TDriveInfo driveInfo;
 
//check all drives from A to Z
for (TInt driveNumber=EDriveA; driveNumber<=EDriveZ; driveNumber++)
{
//Gets information of this drive
fileSession.Drive(driveInfo,driveNumber);
 
//if this drive is EMediaRam,we find drive of RAM
if(driveInfo.iType == EMediaRam)
{
//finding drive of memory , recode its free memory in bytes
fileSession.Volume(volumeInfo,driveNumber);
freeKBytes = volumeInfo.iFree/1024;
freeMemory.Num(freeKBytes);
break;
}
}
 
....
//close RFs session
fileSession.Close();


  • 后记

freeMemory变量以byte为单位指明可用的内存

This page was last modified on 22 December 2011, at 08:06.
34 page views in the last 30 days.