📄 registry.h
字号:
// -------------------------------------------------------------------
// Filename : registry.h
// Description : class declaration of registry routines
// By : John Cruise
// Date : 1996 Mar 25
// Last Modified : 1996 Mar 25
// Notes : Tabstop = 4
// -------------------------------------------------------------------
// Modifications : 1995 Mar 25 John Cruise
// : none as of now
// -------------------------------------------------------------------
#if !defined( _REGISTRY_H )
#define _REGISTRY_H
#include <windows.h>
#include <winreg.h>
class CRegistry {
public:
// constructors
CRegistry( HKEY hKey, LPCTSTR cSubKey, DWORD nOptions=0, REGSAM samDesired=KEY_ALL_ACCESS );
CRegistry();
// create registry function
virtual void Create( DWORD &nDisposition, HKEY hKey, LPCTSTR cName,
DWORD nOptions=REG_OPTION_NON_VOLATILE,
REGSAM samDesired=KEY_ALL_ACCESS,
LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL );
// open registry function
virtual void Open( HKEY hKey, LPCTSTR cSubKey, DWORD nOptions=0,
REGSAM samDesired=KEY_ALL_ACCESS );
// close registry function
virtual void Close();
// delete subkey registry function
virtual void Remove( LPCTSTR cSubKey );
// write registry function
virtual void Write( LPSTR cValueName, CONST BYTE *pData, DWORD nSize, DWORD nType=REG_SZ );
// read registry function
virtual void Read( LPBYTE pDest, DWORD *nSize, DWORD *nType, LPSTR cValueName );
// get last error registry function
virtual LONG GetLastError();
// enumerate the values
virtual BOOL EnumValue( DWORD nIndex, LPSTR szValueName, LPDWORD nValueNameLen,
LPDWORD nType=NULL, LPBYTE lpValue=NULL, LPDWORD nValueSize=NULL );
// enumerate the keys
virtual BOOL EnumKey( DWORD nIndex, LPSTR szKeyName, LPDWORD nKeyNameLen,
PFILETIME stTimeWrite, LPSTR szClass=NULL, LPDWORD nClassLen=NULL );
// save the key to a file
virtual void SaveKey( LPCTSTR szFilename, LPSECURITY_ATTRIBUTES lpSecurity=NULL );
// restore the key from a file
virtual void RestoreKey( LPCTSTR szFilename, DWORD nFlags=0 );
// load the key from a file
virtual void LoadKey( LPCTSTR szSubKey, LPCTSTR szFilename );
// unload the key from the registry
virtual void UnloadKey( LPCTSTR szSubKey );
// destructor
virtual ~CRegistry();
protected:
BOOL m_bIsOpen;
HKEY m_hKey;
LONG m_nLastError;
};
class CRegistryException : public CException
{
public:
virtual int ReportError( UINT nType=MB_OK, UINT nMessageID=0 );
CRegistryException( UINT nError );
virtual ~CRegistryException();
protected:
UINT m_nError;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -