|
#if !defined(AFX_REGKEY_H__E451D194_D4C3_11D1_AB17_0000E8425C3E__INCLUDED_)
#define AFX_REGKEY_H__E451D194_D4C3_11D1_AB17_0000E8425C3E__INCLUDED_
#include <winreg.h>
#include <afxtempl.h>
class CRegKey
{
// Construction
public:
CRegKey();
CRegKey(CRegKey& regKey);
virtual ~CRegKey();
CRegKey& operator=(CRegKey regKey);
// Operations
public:
// note: calling open on an already open key will assert
// you must call Close() first if you want to re-use CRegKey objects
LONG Open(HKEY hKeyRoot, const char* pszPath);
void Close();
CString GetPath() const { return m_sPath; }
HKEY GetKey() const { return m_hKey; }
HKEY GetKeyRoot() const { return m_hKeyRoot; }
LONG Write(const char* pszKey, DWORD dwVal);
LONG Write(const char* pszKey, const char* pszVal);
LONG Write(const char* pszKey, const BYTE* pData, DWORD dwLength);
LONG Read(const char* pszKey, DWORD& dwVal) const;
LONG Read(const char* pszKey, CString& sVal) const;
LONG Read(const char* pszKey, BYTE* pData, DWORD& dwLength) const;
static LONG Delete(HKEY hKeyRoot, const char* pszPath);
static BOOL KeyExists(HKEY hKeyRoot, const char* pszPath);
int GetSubkeyNames(CStringArray& aNames) const;
int GetValueNames(CStringArray& aNames) const;
BOOL HasValues() const;
BOOL ExportToIni(LPCTSTR szIniPath) const;
BOOL ImportFromIni(LPCTSTR szIniPath);
#ifndef _NOT_USING_MFC_
static CString GetAppRegPath(LPCTSTR szAppName = NULL);
#endif
protected:
HKEY m_hKey;
HKEY m_hKeyRoot;
CString m_sPath;
protected:
static LONG RecurseDeleteKey(HKEY key, LPCTSTR lpszKey);
BOOL ExportKeyToIni(const char* pszKey, CStdioFile& file) const;
BOOL ExportValueToIni(DWORD nIndex, CStdioFile& file) const;
BOOL ImportSectionFromIni(const CString& sSection, CStdioFile& file, CString& sNextSection);
};
#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.
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
.dan.g. is a naturalised Australian and has been developing commercial windows software since 1998.