IniReader.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // IniFile.h: interface for the CIniReader class.
  2. /************************************************************************************
  3. // Zero.t 创建日期:2011/12/12;
  4. 函数描述:
  5. setINIFileName 设置ini文件用于写与读;.
  6. getKeyValue 返回指定段名键名的键值;
  7. getSectionData 返回指定的段名的所有数据;
  8. getSectionNames 返回ini所有的段名;
  9. sectionExists 段名是否存在;
  10. setKey 设置键名;
  11. ************************************************************************************/
  12. #ifndef _INIFILE_H_DATA20111212
  13. #define _INIFILE_H_DATA20111212
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif // _MSC_VER > 1000
  17. #include <afxcoll.h>
  18. class CIniReader
  19. {
  20. public:
  21. //int m_iSecCount; // ini文件内所有段数;
  22. int GetSecCount();
  23. int GetKeyCount(/*CString strSec*/);
  24. // 获取文件时间;
  25. //CString GetKeyValueTime(CString strKeyValue);
  26. // 获取文件名;
  27. //CString GetKeyValueFileName(CString strKeyValue);
  28. //int m_iKeyCount; // ini文件内,指定段内的键数;
  29. // 设置没有被指定的ini文件名;
  30. void SetINIFileName(CString strINIFile);
  31. // 返回指定段名的数据信息;
  32. CStringList* GetSectionData(CString strSection);
  33. // 返回段名;
  34. CStringList* GetSectionNames();
  35. // 判断段名是否存在于ini文件中;
  36. BOOL SectionExists(CString strSection);
  37. // 设置指定段名键值;
  38. long SetKey(CString strValue, CString strKey, CString strSection);
  39. // 获取指定段名的键值;
  40. CString GetKeyValueText(CString strKey,CString strSection);
  41. //
  42. int GetKeyValueInt(CString strKey, CString strSection);
  43. // 默认构造函数;
  44. CIniReader()
  45. {
  46. //m_iSecCount = 0;
  47. //m_iKeyCount = 0;
  48. m_sectionList = new CStringList();
  49. m_sectionDataList = new CStringList();
  50. }
  51. CIniReader(CString strFile)
  52. {
  53. //m_iSecCount = 0;
  54. //m_iKeyCount = 0;
  55. m_strFileName = strFile;
  56. m_sectionList = new CStringList();
  57. m_sectionDataList = new CStringList();
  58. }
  59. ~CIniReader()
  60. {
  61. delete m_sectionList;
  62. delete m_sectionDataList;
  63. }
  64. private:
  65. // 保存段名与段数据;
  66. CStringList *m_sectionDataList;
  67. CStringList *m_sectionList;
  68. CString m_strSection;
  69. long m_lRetValue;
  70. // ini文件名;
  71. CString m_strFileName;
  72. };
  73. #endif