www.pudn.com > NetPaw.rar > Registry.h
/* Copyright (c) 1998 Sasha Djolich */
/* For questions or comments, contact the author at djolic@netinfo.ubc.ca */
#pragma once
enum enuMode
{
mode_CurrentUser = 0,
mode_DefaultUser,
mode_LocalMachine,
accessRead = 0x1,
accessWrite = 0x2,
};
class CRegistry
{
public:
// Construction/Destruction
public:
CRegistry(const char* ApplicationName, int Mode = mode_CurrentUser, int Access = accessRead | accessWrite);
CRegistry(HKEY RootKey, const char* Section, int Access = accessRead | accessWrite);
~CRegistry();
// Attributes
public:
void SetSection(const char* ApplicationName, int Mode = mode_CurrentUser);
void SetSection(HKEY RootKey, const char* Section);
void SetAccess(int Access = accessRead | accessWrite);
// Iteration
public:
DWORD GetFirstKeyPos();
CString GetNextKey(DWORD& dwPos);
DWORD GetFirstSectionPos();
CString GetNextSection(DWORD& dwPos);
// Operations
public:
void Descend(const char* Section);
void Ascend();
bool KeyExists(const char* Key);
bool SectionExists(const char* Section);
void Write(const char* Key, signed char Value);
void Write(const char* Key, unsigned char Value);
void Write(const char* Key, signed short Value);
void Write(const char* Key, unsigned short Value);
void Write(const char* Key, signed int Value);
void Write(const char* Key, unsigned int Value);
void Write(const char* Key, signed long Value);
void Write(const char* Key, unsigned long Value);
void Write(const char* Key, float Value);
void Write(const char* Key, double Value);
void Write(const char* Key, const CString& Value);
void Read(const char* Key, signed char& Value);
void Read(const char* Key, unsigned char& Value);
void Read(const char* Key, signed short& Value);
void Read(const char* Key, unsigned short& Value);
void Read(const char* Key, signed int& Value);
void Read(const char* Key, unsigned int& Value);
void Read(const char* Key, signed long& Value);
void Read(const char* Key, unsigned long& Value);
void Read(const char* Key, float& Value);
void Read(const char* Key, double& Value);
void Read(const char* Key, CString& Value);
private:
void OpenKey(HKEY RootKey, const CString& Section, int Access);
void Close();
void WriteDWORD(const char* Key, DWORD Value);
void WriteString(const char* Key, const CString& Value);
void ReadDWORD(const char* Key, DWORD& Value);
void ReadString(const char* Key, CString& Value);
HKEY m_hkRootKey;
CString m_sSection;
HKEY m_hkActiveRootKey;
CString m_sActiveSection;
int m_nAccess;
};