Click here to Skip to main content
13,796,389 members
Click here to Skip to main content

Stats

518.9K views
8.5K downloads
162 bookmarked
Posted 5 Aug 2003
Licenced

VssReporter 2.1 - A Visual SourceSafe reporting tool for build administrators

, 25 Mar 2006
A support tool to allow those performing builds to independently determine exactly what source files have been changed and by whom
#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.

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

Share

About the Author

.dan.g.
Software Developer Maptek
Australia Australia
.dan.g. is a naturalised Australian and has been developing commercial windows software since 1998.

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.181207.3 | Last Updated 25 Mar 2006
Article Copyright 2003 by .dan.g.
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid