Windows Moblie 利用EVC读写INI XML配置文件
2010-08-22 12:59:00 来源:WEB开发网{
strCombine.Insert(iIndexT, strEntry + L"=" + strValue + L" ");
LPTSTR lpCombine = strCombine.GetBuffer(0);
IniFile.SetLength(0);
IniFile.SeekToBegin();
IniFile.Write(lpCombine, strCombine.GetLength() * 2);
IniFile.Close();
return TRUE;
}
else
{
iIndex3 = strCombine.Find(L" ", iIndex2 + 1);
if(iIndex3 == -1)
{
IniFile.Close();
return FALSE;
}
iIndexT = iIndex2 + 1 + strEntry.GetLength();
strCombine.Delete(iIndexT, iIndex3 - iIndexT);
strCombine.Insert(iIndexT, strValue);
LPTSTR lpCombine = strCombine.GetBuffer(0);
IniFile.SetLength(0);
IniFile.SeekToBegin();
IniFile.Write(lpCombine, strCombine.GetLength() * 2);
IniFile.Close();
return TRUE;
}
}
CATCH(CFileException, e)
{
}
END_CATCH
IniFile.Close();
return FALSE;
}
写整型
BOOL CProfile::WriteProfileInt(const CString strSection, const CString strEntry, const int iValue, const CString strIniPath)
{
wchar_t cBuff[MAX_LEN];
CString strValue("");
_itow(iValue, cBuff, 10);
strValue.Format(_T("%s"), cBuff);
return CProfile::WriteProfileString(strSection, strEntry, strValue, strIniPath);
}
2.读配置文件
Code
CString CProfile::GetProfileString(const CString strSection, const CString strEntry, const CString strDefault, const CString strIniPath)
{
if(strSection == L"" || strEntry == L"" || strIniPath == L"")
{
return strDefault;
}
CFile IniFile;
CString strCombine;
TRY
{
更多精彩
赞助商链接