WEB开发网
开发学院手机开发Windows Mobile 开发 Windows Moblie 利用EVC读写INI XML配置文件 阅读

Windows Moblie 利用EVC读写INI XML配置文件

 2010-08-22 12:59:00 来源:WEB开发网   
核心提示:L""){return FALSE;}CFile IniFile;CString strCombine;TRY{if(! IniFile.Open(strIniPath, CFile::modeReadWrite|CFile::modeCreate|CFile::modeNoTruncate)){r
L"")

{

return FALSE;

}

CFile IniFile;

CString strCombine;

TRY

{

if(! IniFile.Open(strIniPath, CFile::modeReadWrite|CFile::modeCreate|CFile::modeNoTruncate))

{

return FALSE;

}

if(IniFile.GetLength() == 0)

{

strCombine = L"[" + strSection + L"]" + L" "

+ strEntry + L"=" + strValue + L" ";

LPTSTR lpCombine = strCombine.GetBuffer(0);

IniFile.Write(lpCombine, strCombine.GetLength() * 2);

IniFile.Close();

return TRUE;

}

WCHAR *pBuf;

pBuf = new WCHAR[IniFile.GetLength() / 2 + 1];

if(pBuf == NULL)

{

IniFile.Close();

return FALSE;

}

if(IniFile.Read(pBuf, IniFile.GetLength()) != IniFile.GetLength())

{

delete[] pBuf;

IniFile.Close();

return FALSE;

}

pBuf[IniFile.GetLength() / 2] = NULL;

strCombine.GetBuffer(MAX_LEN);

strCombine = pBuf;

delete[] pBuf;

int iIndex1, iIndex2, iIndex3, iIndexT;

iIndex1 = strCombine.Find(L"[" + strSection + L"] ");

if(iIndex1 == -1)

{

strCombine += L"[" + strSection + L"]" + L" "

+ strEntry + L"=" + strValue + L" ";

LPTSTR lpCombine = strCombine.GetBuffer(0);

IniFile.SetLength(0);

IniFile.SeekToBegin();

IniFile.Write(lpCombine, strCombine.GetLength() * 2);

IniFile.Close();

return TRUE;

}

//iIndexT = iIndex1 + 4 + strSection.GetLength();

//modify by plr at 2008-11-8

iIndexT = iIndex1 + strSection.GetLength() + 2; //2代表"[]"两个字符

iIndex2 = strCombine.Find(strEntry + L"=", iIndexT);

if(iIndex2 == -1)

上一页  1 2 3 4  下一页

Tags:Windows Moblie 利用

编辑录入:coldstar [复制链接] [打 印]
赞助商链接