void CMyUi::ConstructL() {
BaseConstructL();
RFs fileSession = Document()->Process()->FsSession();
CDictionaryStore* store = Application()->OpenIniFileLC(fileSession);
if (store->IsPresentL(KKey1Uid)) {
RDictionaryReadStream in;
in.OpenLC(*store, KKey1Uid);
in >> *iMyConfig;
CleanupStack: opAndDestroy();
} else {
iMyConfig->SetDefault();
RDictionaryWriteStream out;
out.AssignLC(*store, KKey1Uid);
out << *iMyConfig;
out.CommitL();
CleanupStack: opAndDestroy();
store->CommitL();
}
CleanupStack: opAndDestroy();
//...
}
BaseConstructL();
RFs fileSession = Document()->Process()->FsSession();
CDictionaryStore* store = Application()->OpenIniFileLC(fileSession);
if (store->IsPresentL(KKey1Uid)) {
RDictionaryReadStream in;
in.OpenLC(*store, KKey1Uid);
in >> *iMyConfig;
CleanupStack: opAndDestroy();
} else {
iMyConfig->SetDefault();
RDictionaryWriteStream out;
out.AssignLC(*store, KKey1Uid);
out << *iMyConfig;
out.CommitL();
CleanupStack: opAndDestroy();
store->CommitL();
}
CleanupStack: opAndDestroy();
//...
}
博客给出了一段Symbian应用中操作Ini文件的代码。在CMyUi类的ConstructL函数里,通过文件会话打开Ini文件,判断特定键是否存在,若存在则读取配置,不存在则设置默认配置并写入,最后进行提交操作。
703

被折叠的 条评论
为什么被折叠?



