WEB开发网
开发学院手机开发Windows Mobile 开发 在Windows mobile 5.0下操作INI文件 阅读

在Windows mobile 5.0下操作INI文件

 2010-08-22 12:58:00 来源:WEB开发网   
核心提示:1)* sizeof(TCHAR));nSize += szTemp1.GetLength() + 1;return FALSE;}}return TRUE;}2。写INIBOOL WriteInIFile(CString strSection,CString strEntry,CString strValue){if
1)* sizeof(TCHAR));

nSize += szTemp1.GetLength() + 1;

return FALSE;

}

}

return TRUE;

}

2。写INI

BOOL WriteInIFile(CString strSection,CString strEntry,CString strValue)

{

if(strSection == L"" || strEntry == L"" || strValue == L"")

{

return FLASE;

}

CFile iniFile;

CString strCombine;

if(!iniFile.Open(L"ini文件所在路", CFile::modeReadWrite|CFile::modeCreate|CFile::modeNoTruncate))

{

return FLASE;

}

DWORD dwFilesize = iniFile.GetLength() / 2 + 1;

WCHAR *pBuf;

try

{

pBuf = new WCHAR[dwFilesize];

}

catch(...)

{

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 FLASE;

}

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

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

if(iIndex2 == -1)

{

strCombine.Insert(iIndexT, strEntry + L"=" + strValue + L"

上一页  1 2 3 4 5 6  下一页

Tags:Windows mobile 操作

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