ini文件的創建讀寫
創建ini文件:
void CFrozenBubbleAppUi::WriteIniFile(TUid iInfo, void *ptr, TUint size){
TInt r;
RFs fs;
fs.Connect();
CleanupClosePushL( fs );
RDictionaryWriteStream rdsIniFile;
CDictionaryStore *cdIniFile = Application()->OpenIniFileLC(fs);//如果不存在就創建
rdsIniFile.AssignLC(*cdIniFile, iInfo);
TPtr8 buf((TUint8*)ptr, size, size);
TRAP(r, rdsIniFile.WriteL(buf));
rdsIniFile.CommitL();
CleanupStack::PopAndDestroy();
cdIniFile->CommitL();
CleanupStack::PopAndDestroy( 2 );
}
讀ini文件:
TBool CFrozenBubbleAppUi::ReadIniFile(TUid iInfo, void *ptr, TUint &size){
TInt r;
TBool result = EFalse;
RFs fs;
fs.Connect();
CleanupClosePushL( fs );
RDictionaryReadStream rdsIniFile;
CDictionaryStore *cdIniFile = Application()->OpenIniFileLC(fs);
if (cdIniFile->IsPresentL(iInfo)){
rdsIniFile.OpenLC(*cdIniFile, iInfo);
TPtr8 buf((TUint8*)ptr, size);
TRAP(r, rdsIniFile.ReadL(buf));
CleanupStack::PopAndDestroy(); // rdsIniFile
result = ETrue;
}
CleanupStack::PopAndDestroy( 2 ); // fs, cdIniFile
return result;
}
| 只有注冊用戶登錄后才能發表評論。 | ||
|
||
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
|
||
|
|