OSDN Git Service

* use SendMessageTimeout() instead of PostMessage()
[yamy/yamy.git] / registry.h
index 531c62d..c5271fe 100644 (file)
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// registry.h
-
-
-#ifndef _REGISTRY_H
-#  define _REGISTRY_H
-
-#  include "stringtool.h"
-#  include <list>
-
-
-/// registry access class
-class Registry
-{
-  HKEY m_root;                                 /// registry root
-  tstring m_path;                              /// path from registry root
-
-public:
-  typedef std::list<tstring> tstrings;
-  
-public:
-  ///
-  Registry() : m_root(NULL) { setRoot(NULL, _T("")); }
-  ///
-  Registry(HKEY i_root, const tstring &i_path)
-    : m_root(i_root), m_path(i_path) { setRoot(i_root, i_path); }
-  
-  /// set registry root and path
-  void setRoot(HKEY i_root, const tstring &i_path)
-  {
-    m_root = i_root;
-    m_path = i_path;
-    _TCHAR exePath[GANA_MAX_PATH];
-    _TCHAR exeDrive[GANA_MAX_PATH];
-    _TCHAR exeDir[GANA_MAX_PATH];
-    GetModuleFileName(NULL, exePath, GANA_MAX_PATH);
-    _tsplitpath_s(exePath, exeDrive, GANA_MAX_PATH, exeDir, GANA_MAX_PATH, NULL, 0, NULL, 0);
-    m_path = exeDrive;
-    m_path += exeDir;
-    m_path += _T("yamy.ini");
-  }
-  
-  /// remvoe
-  bool remove(const tstring &i_name = _T("")) const
-  { return remove(m_root, m_path, i_name); }
-  
-  /// does exist the key ?
-  bool doesExist() const { return doesExist(m_root, m_path); }
-
-  /// read DWORD
-  bool read(const tstring &i_name, int *o_value, int i_defaultValue = 0)
-    const
-  { return read(m_root, m_path, i_name, o_value, i_defaultValue); }
-  /// write DWORD
-  bool write(const tstring &i_name, int i_value) const
-  { return write(m_root, m_path, i_name, i_value); }
-  /// read tstring
-  bool read(const tstring &i_name, tstring *o_value, 
-           const tstring &i_defaultValue = _T("")) const
-  { return read(m_root, m_path, i_name, o_value, i_defaultValue); }
-  /// write tstring
-  bool write(const tstring &i_name, const tstring &i_value) const
-  { return write(m_root, m_path, i_name, i_value); }
-
-#ifndef USE_INI
-  /// read list of tstring
-  bool read(const tstring &i_name, tstrings *o_value, 
-           const tstrings &i_defaultValue = tstrings()) const
-  { return read(m_root, m_path, i_name, o_value, i_defaultValue); }
-  /// write list of tstring
-  bool write(const tstring &i_name, const tstrings &i_value) const
-  { return write(m_root, m_path, i_name, i_value); }
-
-  /// read binary data
-  bool read(const tstring &i_name, BYTE *o_value, DWORD i_valueSize,
-           const BYTE *i_defaultValue = NULL, DWORD i_defaultValueSize = 0)
-    const
-  { return read(m_root, m_path, i_name, o_value, i_valueSize, i_defaultValue,
-               i_defaultValueSize); }
-  /// write binary data
-  bool write(const tstring &i_name, const BYTE *i_value,
-            DWORD i_valueSize) const
-  { return write(m_root, m_path, i_name, i_value, i_valueSize); }
-#endif //!USE_INI
-
-public:
-  /// remove
-  static bool remove(HKEY i_root, const tstring &i_path,
-                    const tstring &i_name = _T(""));
-  
-  /// does exist the key ?
-  static bool doesExist(HKEY i_root, const tstring &i_path);
-  
-  /// read DWORD
-  static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
-                  int *o_value, int i_defaultValue = 0);
-  /// write DWORD
-  static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
-                   int i_value);
-
-  /// read tstring
-  static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
-                  tstring *o_value, const tstring &i_defaultValue = _T(""));
-  /// write tstring
-  static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
-                   const tstring &i_value);
-  
-#ifndef USE_INI
-  /// read list of tstring
-  static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
-                  tstrings *o_value, const tstrings &i_defaultValue = tstrings());
-  /// write list of tstring
-  static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
-                   const tstrings &i_value);
-  
-  /// read binary data
-  static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
-                  BYTE *o_value, DWORD i_valueSize,
-                  const BYTE *i_defaultValue = NULL,
-                  DWORD i_defaultValueSize = 0);
-  /// write binary data
-  static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
-                   const BYTE *i_value, DWORD i_valueSize);
-#endif //!USE_INI
-  /// read LOGFONT
-  static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,
-                  LOGFONT *o_value, const tstring &i_defaultStringValue);
-  /// write LOGFONT
-  static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,
-                   const LOGFONT &i_value);
-};
-
-
-#endif // !_REGISTRY_H
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+// registry.h\r
+\r
+\r
+#ifndef _REGISTRY_H\r
+#  define _REGISTRY_H\r
+\r
+#  include "stringtool.h"\r
+#  include <list>\r
+\r
+\r
+/// registry access class\r
+class Registry\r
+{\r
+       HKEY m_root;                                    /// registry root\r
+       tstring m_path;                         /// path from registry root\r
+\r
+public:\r
+       typedef std::list<tstring> tstrings;\r
+\r
+public:\r
+       ///\r
+       Registry() : m_root(NULL) {\r
+               setRoot(NULL, _T(""));\r
+       }\r
+       ///\r
+       Registry(HKEY i_root, const tstring &i_path)\r
+                       : m_root(i_root), m_path(i_path) {\r
+               setRoot(i_root, i_path);\r
+       }\r
+\r
+       /// set registry root and path\r
+       void setRoot(HKEY i_root, const tstring &i_path) {\r
+               m_root = i_root;\r
+               if (m_root) {\r
+                       m_path = i_path;\r
+               } else {\r
+                       _TCHAR exePath[GANA_MAX_PATH];\r
+                       _TCHAR exeDrive[GANA_MAX_PATH];\r
+                       _TCHAR exeDir[GANA_MAX_PATH];\r
+                       GetModuleFileName(NULL, exePath, GANA_MAX_PATH);\r
+                       _tsplitpath_s(exePath, exeDrive, GANA_MAX_PATH, exeDir, GANA_MAX_PATH, NULL, 0, NULL, 0);\r
+                       m_path = exeDrive;\r
+                       m_path += exeDir;\r
+                       m_path += _T("yamy.ini");\r
+               }\r
+       }\r
+\r
+       /// remvoe\r
+       bool remove(const tstring &i_name = _T("")) const {\r
+               return remove(m_root, m_path, i_name);\r
+       }\r
+\r
+       /// does exist the key ?\r
+       bool doesExist() const {\r
+               return doesExist(m_root, m_path);\r
+       }\r
+\r
+       /// read DWORD\r
+       bool read(const tstring &i_name, int *o_value, int i_defaultValue = 0)\r
+       const {\r
+               return read(m_root, m_path, i_name, o_value, i_defaultValue);\r
+       }\r
+       /// write DWORD\r
+       bool write(const tstring &i_name, int i_value) const {\r
+               return write(m_root, m_path, i_name, i_value);\r
+       }\r
+\r
+       /// read tstring\r
+       bool read(const tstring &i_name, tstring *o_value,\r
+                         const tstring &i_defaultValue = _T("")) const {\r
+               return read(m_root, m_path, i_name, o_value, i_defaultValue);\r
+       }\r
+       /// write tstring\r
+       bool write(const tstring &i_name, const tstring &i_value) const {\r
+               return write(m_root, m_path, i_name, i_value);\r
+       }\r
+\r
+#ifndef USE_INI\r
+       /// read list of tstring\r
+       bool read(const tstring &i_name, tstrings *o_value,\r
+                         const tstrings &i_defaultValue = tstrings()) const {\r
+               return read(m_root, m_path, i_name, o_value, i_defaultValue);\r
+       }\r
+       /// write list of tstring\r
+       bool write(const tstring &i_name, const tstrings &i_value) const {\r
+               return write(m_root, m_path, i_name, i_value);\r
+       }\r
+#endif //!USE_INI\r
+\r
+       /// read binary data\r
+       bool read(const tstring &i_name, BYTE *o_value, DWORD *i_valueSize,\r
+                         const BYTE *i_defaultValue = NULL, DWORD i_defaultValueSize = 0)\r
+       const {\r
+               return read(m_root, m_path, i_name, o_value, i_valueSize, i_defaultValue,\r
+                                       i_defaultValueSize);\r
+       }\r
+       /// write binary data\r
+       bool write(const tstring &i_name, const BYTE *i_value,\r
+                          DWORD i_valueSize) const {\r
+               return write(m_root, m_path, i_name, i_value, i_valueSize);\r
+       }\r
+\r
+public:\r
+       /// remove\r
+       static bool remove(HKEY i_root, const tstring &i_path,\r
+                                          const tstring &i_name = _T(""));\r
+\r
+       /// does exist the key ?\r
+       static bool doesExist(HKEY i_root, const tstring &i_path);\r
+\r
+       /// read DWORD\r
+       static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
+                                        int *o_value, int i_defaultValue = 0);\r
+       /// write DWORD\r
+       static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
+                                         int i_value);\r
+\r
+       /// read tstring\r
+       static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
+                                        tstring *o_value, const tstring &i_defaultValue = _T(""));\r
+       /// write tstring\r
+       static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
+                                         const tstring &i_value);\r
+\r
+#ifndef USE_INI\r
+       /// read list of tstring\r
+       static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
+                                        tstrings *o_value, const tstrings &i_defaultValue = tstrings());\r
+       /// write list of tstring\r
+       static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
+                                         const tstrings &i_value);\r
+#endif //!USE_INI\r
+\r
+       /// read binary data\r
+       static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
+                                        BYTE *o_value, DWORD *i_valueSize,\r
+                                        const BYTE *i_defaultValue = NULL,\r
+                                        DWORD i_defaultValueSize = 0);\r
+       /// write binary data\r
+       static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
+                                         const BYTE *i_value, DWORD i_valueSize);\r
+       /// read LOGFONT\r
+       static bool read(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
+                                        LOGFONT *o_value, const tstring &i_defaultStringValue);\r
+       /// write LOGFONT\r
+       static bool write(HKEY i_root, const tstring &i_path, const tstring &i_name,\r
+                                         const LOGFONT &i_value);\r
+};\r
+\r
+\r
+#endif // !_REGISTRY_H\r