引用自:
http://www.sf.org.cn/Article/symbiandev/200509/188.html
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;
}