1
0

config.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef _C_CONFIG_H_
  2. #define _C_CONFIG_H_
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #define C_CONFIG_WIN32NATIVE
  7. #include <windows.h>
  8. class C_Config
  9. {
  10. public:
  11. C_Config(LPCTSTR pszIniFile);
  12. ~C_Config();
  13. void WriteIntEx(LPCTSTR pszSection, LPCTSTR pszKey, int nValue);
  14. void WriteStringEx(LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszValue);
  15. int ReadIntEx(LPCTSTR pszSection, LPCTSTR pszKey, int nDefault);
  16. LPTSTR ReadCchStringEx(LPTSTR pszBuffer, INT cchBuffer, LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszDefault);
  17. LPTSTR ReadCbStringEx(LPTSTR pszBuffer, INT cbBuffer, LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszDefault);
  18. DWORD GetStringEx(LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszDefault, LPTSTR pszReturnedValue, DWORD nSize);
  19. void WriteBoolEx(LPCTSTR pszSection, LPCTSTR pszKey, int nValue) { WriteIntEx(pszSection, pszKey, ( 0 != nValue)); }
  20. BOOL ReadBoolEx(LPCTSTR pszSection, LPCTSTR pszKey, int nDefault) { return (0 != ReadIntEx(pszSection, pszKey, nDefault)); }
  21. LPTSTR ReadCchQuotedString(LPTSTR pszBuffer, INT cchBuffer, LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszDefault);
  22. LPTSTR ReadCbQuotedString(LPTSTR pszBuffer, INT cbBuffer, LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszDefault);
  23. void WriteQuotedString(LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszValue);
  24. void WriteInt(LPCTSTR pszKey, int nValue);
  25. void WriteString(LPCTSTR pszKey, LPCTSTR pszValue);
  26. int ReadInt(LPCTSTR pszKey, int nDefault);
  27. LPCTSTR ReadString(LPCTSTR pszKey, LPCTSTR pszDefault);
  28. DWORD GetString(LPCTSTR pszKey, LPCTSTR pszDefault, LPTSTR pszReturnedValue, DWORD nSize);
  29. void WriteBool(LPCTSTR pszKey, int nValue) { WriteInt(pszKey, ( 0 != nValue)); }
  30. BOOL ReadBool(LPCTSTR pszKey, int nDefault) { return (0 != ReadInt(pszKey, nDefault)); }
  31. private:
  32. TCHAR *m_inifile;
  33. };
  34. #endif//_C_CONFIG_H_