// IniFile.h: interface for the CIniReader class. /************************************************************************************ // Zero.t 创建日期:2011/12/12; 函数描述: setINIFileName 设置ini文件用于写与读;. getKeyValue 返回指定段名键名的键值; getSectionData 返回指定的段名的所有数据; getSectionNames 返回ini所有的段名; sectionExists 段名是否存在; setKey 设置键名; ************************************************************************************/ #ifndef _INIFILE_H_DATA20111212 #define _INIFILE_H_DATA20111212 #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include class CIniReader { public: //int m_iSecCount; // ini文件内所有段数; int GetSecCount(); int GetKeyCount(/*CString strSec*/); // 获取文件时间; //CString GetKeyValueTime(CString strKeyValue); // 获取文件名; //CString GetKeyValueFileName(CString strKeyValue); //int m_iKeyCount; // ini文件内,指定段内的键数; // 设置没有被指定的ini文件名; void SetINIFileName(CString strINIFile); // 返回指定段名的数据信息; CStringList* GetSectionData(CString strSection); // 返回段名; CStringList* GetSectionNames(); // 判断段名是否存在于ini文件中; BOOL SectionExists(CString strSection); // 设置指定段名键值; long SetKey(CString strValue, CString strKey, CString strSection); // 获取指定段名的键值; CString GetKeyValueText(CString strKey,CString strSection); // int GetKeyValueInt(CString strKey, CString strSection); // 默认构造函数; CIniReader() { //m_iSecCount = 0; //m_iKeyCount = 0; m_sectionList = new CStringList(); m_sectionDataList = new CStringList(); } CIniReader(CString strFile) { //m_iSecCount = 0; //m_iKeyCount = 0; m_strFileName = strFile; m_sectionList = new CStringList(); m_sectionDataList = new CStringList(); } ~CIniReader() { delete m_sectionList; delete m_sectionDataList; } private: // 保存段名与段数据; CStringList *m_sectionDataList; CStringList *m_sectionList; CString m_strSection; long m_lRetValue; // ini文件名; CString m_strFileName; }; #endif