summaryrefslogtreecommitdiff
path: root/src/w32dlib/registry.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32dlib/registry.h')
-rw-r--r--src/w32dlib/registry.h147
1 files changed, 147 insertions, 0 deletions
diff --git a/src/w32dlib/registry.h b/src/w32dlib/registry.h
new file mode 100644
index 0000000..7dc38f0
--- /dev/null
+++ b/src/w32dlib/registry.h
@@ -0,0 +1,147 @@
+// w32dlib - Win32 Dialog Helpers
+//
+// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// -------------------------------------------------------------------------
+//
+#ifndef W32DLIB_REGISTRY_H
+
+#define W32DLIB_REGISTRY_H "$Id$"
+
+#include "w32dlib/base.h"
+
+namespace W32DLib
+{
+
+ /// \brief The Registry class.
+ ///
+ /// Gives basic registry access.
+ ///
+ class Registry
+ {
+ public:
+
+ /// \brief Opens the supplied registry key read/write
+ ///
+ /// \param root The root of the key (use Windows HKEY_xxx constants).
+ /// \param path The path to the key.
+ /// \param permanent If false then the key is created volatile (ie. not
+ /// saved to disk). This is ignored by Windows for Win9X.
+ ///
+ Registry(HKEY root, const char *path, bool permanent);
+
+ /// \brief Opens the supplied registry key read only
+ ///
+ /// \param root The root of the key (use Windows HKEY_xxx constants).
+ /// \param path The path to the key.
+ ///
+ Registry(HKEY root, const char *path);
+
+ /// \brief Destructor.
+ ///
+ /// This closes the registry key.
+ ///
+ virtual ~Registry();
+
+
+ /// \brief Sees whether the key was opened.
+ ///
+ /// \return True if the key was created/opened OK.
+ ///
+ bool IsOpen();
+
+
+ /// \brief Reads a boolean value from the registry.
+ ///
+ /// Booleans are implemented as a DWORD entry with a value 1 or 0.
+ ///
+ /// \param name The name of the value.
+ /// \param val A reference to a place to store the result.
+ /// \return True if the value could be read.
+ ///
+ bool Read(const char *name, bool& val);
+
+
+ /// \brief Reads an integer value from the registry.
+ ///
+ /// \param name The name of the value.
+ /// \param val A reference to a place to store the result.
+ /// \return True if the value could be read.
+ ///
+ bool Read(const char *name, unsigned& val);
+
+
+ /// \brief Reads a string value from the registry.
+ ///
+ /// \param name The name of the value.
+ /// \param val A reference to a place to store the result.
+ /// \return True if the value could be read.
+ ///
+ bool Read(const char *name, std::string& val);
+
+
+ /// \brief Writes a boolean value to the registry.
+ ///
+ /// Booleans are implemented as a DWORD entry with a value 1 or 0.
+ ///
+ /// \param name The name of the value.
+ /// \param val The value.
+ /// \return True if the value could be read.
+ ///
+ bool Write(const char *name, bool val);
+
+
+ /// \brief Writes an integer value to the registry.
+ ///
+ /// \param name The name of the value.
+ /// \param val The value.
+ /// \return True if the value was written.
+ ///
+ bool Write(const char *name, unsigned val);
+
+
+ /// \brief Writes a string value to the registry.
+ ///
+ /// \param name The name of the value.
+ /// \param val The value.
+ /// \return True if the value was written.
+ ///
+ bool Write(const char *name, const char *val);
+
+
+ /// \brief Writes a string value to the registry.
+ ///
+ /// \param name The name of the value.
+ /// \param val The value.
+ /// \return True if the value was written.
+ ///
+ bool Write(const char *name, const std::string& val);
+
+
+ private:
+
+ HKEY m_key;
+ LONG m_openres;
+
+ }; // class Registry
+
+}; // namespace w32dlib
+
+#endif // W32DLIB_REGISTRY_H
+
+
+// END OF FILE