Symbian 读写 INI 配置文件的方法
2010-04-20 16:06:00 来源:WEB开发网};
////////////////////////////////////////////////////////////
#endif //__C_INI_FILE_H__
////////////////////////////////////////////////////////////
//How to use:
//TBuf<128> path;
//path.Format(_L(“c:\cbm\cbm.ini”));
//CIniFile *ini = CIniFile::NewL(path);
//ini->OpenIni();
//
//TBuf8<256> sChannels;
//ini->GetValue(_L8(“cbm”), _L8(“channels”), sChannels);
//
//TBuf8<4> flag = _L8(“1″);
//ini->PutValue(sChannel, _L8(“flag”), flag);
//
//ini->CloseIni();
//delete ini;
//CIniFile.cpp
////////////////////////////////////////////////////////////////
#include “CIniFile.h”
////////////////////////////////////////////////////////////////
CIniFile *CIniFile::NewL(const TDesC &p_fileName)
{
CIniFile *self = CIniFile::NewLC(p_fileName);
CleanupStack::Pop(self);
return self;
}
CIniFile *CIniFile::NewLC(const TDesC &p_fileName)
{
CIniFile *self = new(ELeave) CIniFile(p_fileName);
CleanupStack::PushL(self);
return self;
}
CIniFile::CIniFile(const TDesC &p_fileName):CFile(p_fileName)
{
m_pIniElements = NULL;
}
void CIniFile::DostroyL()
{
for(int i = 0; i
delete m_pIniElements->At(i);
delete m_pIniElements;
}
CIniFile::~CIniFile()
{
DostroyL();
}
TInt CIniFile::OpenIni()
{
ConstructL(EFileRead | EFileWrite) ;
TInt pos=0;
FSeek(ESeekStart,pos);
HBufC8 *bufc = HBufC8::NewL(mFileSize + 3); //????ĩβ??ӵ?
赞助商链接