Click here to Skip to main content
15,896,606 members
Articles / Desktop Programming / MFC

A Registry Class

Rate me:
Please Sign up or sign in to vote.
4.55/5 (9 votes)
27 Mar 200121 min read 83.6K   1.4K   45  
This represents a handy set of classes I built to ease the pain of dealing with the Registry.
/*****************************************************************************
*           Change Log
*  Date     | Change
*-----------+-----------------------------------------------------------------
* 30-Aug-99 | [1.384] Created change log
* 30-Aug-99 | [1.384] Added RegistryGUID
*****************************************************************************/
class RegistryVar {
    public:
	static void setInt(UINT id, int value, HKEY root = HKEY_CURRENT_USER);
	static int getInt(UINT id, int def = 0, HKEY root = HKEY_CURRENT_USER);
	static void setString(UINT id, LPCTSTR s, HKEY root = HKEY_CURRENT_USER);
	static CString getString(UINT id, LPCTSTR def = NULL, HKEY root = HKEY_CURRENT_USER);
	static void setGUID(UINT id, const GUID & value, HKEY root = HKEY_CURRENT_USER);
	static GUID getGUID(UINT id, GUID * def, HKEY root = HKEY_CURRENT_USER);
    protected:
	UINT id;
	HKEY root;
	       };
/*lint -e1735 */
class RegistryInt : public RegistryVar {
     public:
         RegistryInt(UINT n, HKEY r = HKEY_CURRENT_USER ) {id = n; root = r; value = 0; } 
	int value; // the value
	virtual int load(int def = 0);
	virtual void store();
				       };
	    

class RegistryString : public RegistryVar {
     public:
	RegistryString(UINT n, HKEY r = HKEY_CURRENT_USER) {id = n; root = r; }
	CString value; // the value
	virtual CString load(LPCTSTR def = NULL);
	virtual void store();
				       };
#ifdef GUID_DEFINED
class RegistryGUID : public RegistryVar {
    public:
       RegistryGUID(UINT n, HKEY r = HKEY_CURRENT_USER) {id = n; root = r; }
       GUID value; // the value
       virtual GUID * load(GUID * def = NULL);
       virtual void store();
};
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Retired
United States United States
PhD, Computer Science, Carnegie Mellon University, 1975
Certificate in Forensic Science and the Law, Duquesne University, 2008

Co-Author, [i]Win32 Programming[/i]

Comments and Discussions