#pragma once #include "stdafx.h" class CMacroFile { public: CMacroFile() { Clear(); } ~CMacroFile() { Clear(); } void Clear() { m_arTiltleLine.RemoveAll(); m_arValueLine.RemoveAll(); } BOOL Read(const TCHAR* lpstrFilePath) { CStdioFile file; CFileException ex; if ( !file.Open(lpstrFilePath, CFile::modeRead, &ex)) { #ifdef _DEBUG TCHAR szCause[255] = {0}; ex.GetErrorMessage(szCause, 255); TRACE(szCause); #endif return FALSE; } CString strLine; CString strTiltle, strValue; int p = 0; while(file.ReadString(strLine)) { strTiltle = _T(""); strValue = _T(""); if ( -1 == (p = strLine.Find(_T('='), 0))) continue; strTiltle = strLine.Left(p); strValue = strLine.Right(strLine.GetLength() - p - 1); m_arTiltleLine.Add(strTiltle); m_arValueLine.Add(strValue); } file.Close(); return TRUE; } BOOL Write(const TCHAR* lpstrFilePath) { CStdioFile file; CFileException ex; if ( !file.Open(lpstrFilePath, CFile::modeCreate | CFile::modeWrite, &ex)) { #ifdef _DEBUG TCHAR szCause[255] = {0}; ex.GetErrorMessage(szCause, 255); TRACE(szCause); #endif return FALSE; } CString strLine = _T(""); CString strTiltle, strValue; for(int nIndex=0; nIndex 0); ZeroMemory(lpBuffer, sizeof(char)*nMaxLength); CString strText = _T(""); for(int nIndex=0; nIndex 0); ZeroMemory(lpBuffer, sizeof(char)*nMaxLength); CString strTitle , strValue ; for(int nIndex=0; nIndex nMaxLength) break; _tcscat_s(lpBuffer, strValue.GetLength(), (LPCTSTR)strValue); _tcscat_s(lpBuffer, 1, _T("\n")); } } } } void SetItem(const TCHAR* lpstrStartChar, const TCHAR* lpstrEndChar, const TCHAR* lpstrMacroFormat, ...) { va_list list; TCHAR strText[2000] = {0}; va_start(list, lpstrMacroFormat); _vstprintf_s(strText, lpstrMacroFormat, list); va_end(list); CString strTitle , strValue ; BOOL bNewItem = TRUE; for(int nIndex=0; nIndex