Click here to Skip to main content
15,886,724 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.5K   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
*-----------+-----------------------------------------------------------------
*  2-May-00 | [2.0.0.907] Created
*  2-May-00 | [2.0.0.907] Added Get/SetWindowPlacement
*****************************************************************************/
BOOL GetRegistryString(HKEY root, const CString &var, CString &val);
BOOL SetRegistryString(HKEY root, const CString &var, const CString &val);
BOOL GetRegistryString(HKEY root, const CString &path, const CString &var, CString &val);
BOOL SetRegistryString(HKEY root, const CString &path, const CString &var, const CString &val);
BOOL GetRegistryString(HKEY root, const CString &path, UINT var, CString &val);
BOOL SetRegistryString(HKEY root, const CString &path, UINT var, const CString &val);

BOOL GetRegistryInt(HKEY root, const CString &var, DWORD &val);
BOOL SetRegistryInt(HKEY root, const CString &var, DWORD val);
BOOL GetRegistryInt(HKEY root, const CString &path, const CString &var, DWORD & val);
BOOL SetRegistryInt(HKEY root, const CString &path, const CString &var, DWORD val);
BOOL GetRegistryInt(HKEY root, const CString &path, UINT var, DWORD &val);
BOOL SetRegistryInt(HKEY root, const CString &path, UINT var, DWORD val);

BOOL GetRegistryInt64(HKEY root, const CString &var, ULONGLONG &val);
BOOL SetRegistryInt64(HKEY root, const CString &var, ULONGLONG val);

BOOL GetRegistryGUID(HKEY root, const CString &var, GUID &val);
BOOL SetRegistryGUID(HKEY root, const CString &var, const GUID &val);

BOOL GetRegistryFont(HKEY root, const CString & var, LPLOGFONT f);
BOOL SetRegistryFont(HKEY root, const CString & var, const LOGFONT * f);

#ifdef IDS_KEY_PLACEMENT_FLAGS
BOOL GetRegistryWindowPlacement(HKEY root, const CString & var, WINDOWPLACEMENT * wp);
BOOL SetRegistryWindowPlacement(HKEY root, const CString & var, const WINDOWPLACEMENT * wp);
#endif

BOOL DeleteRegistryValue(HKEY root, const CString & var);
BOOL DeleteRegistryKey(HKEY root, const CString & keyname);

BOOL GetRegistryKey(HKEY root, const CString & name, HKEY & key);
BOOL FindRegistryKey(HKEY root, const CString & keyname, HKEY & key);

CStringArray * EnumRegistryKeys(HKEY root, const CString & group);
CStringArray * EnumRegistryValues(HKEY root, const CString & group);

CDWordArray * GetRegistryDWordArray(HKEY root, const CString &var);
BOOL SetRegistryDWordArray(HKEY root, const CString & var, CDWordArray & data);

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