⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 registry.h

📁 A Model-View-Controller Framework that integrates with the MFC Doc/View architecture.
💻 H
📖 第 1 页 / 共 2 页
字号:
//------------------------------------------------------------------------------
//$Workfile: Registry.H $
//$Header: /DevNet/SbjCore/SbjCore/Sys/Registry.H 1     4/02/07 4:56p Steve $
//
// Stingray Software Extension Classes
// Copyright (C) 1995 Stingray Software Inc,
// All rights reserved
//   		
//
//$Revision: 1 $
//
//@doc
//
//@module Registry | Renamed Stingray registry class (to break full SEC dependency
//
//-----------------------------------------------------------------------------

#pragma once

#ifdef WIN32
#ifndef _WINREG_
#include "winreg.h"
#endif
#endif


// defines for Win16 compatibility and convenience
#define THIS_SUB_KEY FALSE
#define ALL_SUB_KEYS TRUE

#define SIGNAL_EVENT	TRUE
#define WAIT_FOR_CHANGE	FALSE

#ifndef WIN32
#define ERROR_INVALID_HANDLE 100
#endif

#ifndef WIN32
#define SECPBYTE LPTSTR
#else
#define SECPBYTE LPBYTE
#endif

namespace SbjCore
{
	namespace Sys
	{

		/** the Registry class lifted from Stingray to break the Stingray dependency, see Stringray documentation for details.
		*/
		class AFX_EXT_CLASS Registry : public CObject
		{
			DECLARE_DYNAMIC( Registry );

		// Enumerations for Registry
		public:
		#ifdef WIN32	


			//@devnote
			// The following static data members were not accessed
			// correctly when compiled as an extension dll and have
			// been removed from this class.  Please use the corresponding 
			// constants defined in WINREG.H:
			//
			//static HKEY hKeyLocalMachine;		//	HKEY_LOCAL_MACHINE<nl>
			//static HKEY hKeyClassesRoot;		//	HKEY_CLASSES_ROOT<nl>
			//static HKEY hKeyUsers;			//	HKEY_USERS<nl>
			//static HKEY hKeyCurrentUser;		//	HKEY_CURRENT_USER<nl>
			
			//@cmember,menum
			/* Creation dispositions*/
			enum CreationDisposition
			{
			dispositionCreatedNewKey	 = REG_CREATED_NEW_KEY,		//@@emem New Registry Key created
			dispositionOpenedExistingKey = REG_OPENED_EXISTING_KEY	//@@emem Existing Key opened
			} ;
			
			//@cmember,menum
			/* Create options*/
			enum CreateOptions
			{
			optionsNonVolatile =	REG_OPTION_NON_VOLATILE,		//@@emem Key is preserved when system is rebooted
			optionsVolatile	=		REG_OPTION_VOLATILE				//@@emem Key is not preserved when system is rebooted
			} ;
			
			//@cmember,menum
			/* Create Permissions*/
			enum CreatePermissions
			{
			permissionAllAccess			= KEY_ALL_ACCESS,			//@@emem All key access permissions.
			permissionCreateLink		= KEY_CREATE_LINK,			//@@emem Permission to create symbolic links.
			permissionCreateSubKey		= KEY_CREATE_SUB_KEY,		//@@emem Permission to create subkeys.
			permissionEnumerateSubKeys	= KEY_ENUMERATE_SUB_KEYS,	//@@emem Permission to enumerate subkeys
			permissionExecute			= KEY_EXECUTE,				//@@emem Permission to execute.
			permissionNotify			= KEY_NOTIFY,				//@@emem Permission to notify.
			permissionQueryValue		= KEY_QUERY_VALUE,			//@@emem Permission to query values.
			permissionRead				= KEY_READ,					//@@emem Permission to read.
			permissionSetValue			= KEY_SET_VALUE,			//@@emem Permission to set values.
			permissionWrite				= KEY_WRITE					//@@emem Permission to write.
			} ;

			//@cmember,menum
			/* Key value types*/
			enum KeyValueTypes
			{
			typeBinary					= REG_BINARY,				//@@emem Free form binary data (32-bit only)
			typeDoubleWord				= REG_DWORD,				//@@emem 32-bit number (32-bit only)
			typeDoubleWordLittleEndian	= REG_DWORD_LITTLE_ENDIAN,	//@@emem 32-bit number (same as REG_DWORD) (32-bit only)
			typeDoubleWordBigEndian		= REG_DWORD_BIG_ENDIAN,		//@@emem 32-bit number (32-bit only)
			typeUnexpandedString		= REG_EXPAND_SZ,			//@@emem Unicode nul terminated string (32-bit only)
			typeSymbolicLink			= REG_LINK,					//@@emem Symbolic Link (unicode) (32-bit only)
			typeMultipleString			= REG_MULTI_SZ,				//@@emem Multiple Unicode strings (32-bit only)
			typeNone					= REG_NONE,					//@@emem No value type (32-bit only)
			typeResourceList			= REG_RESOURCE_LIST,		//@@emem Resource list in the resource map (32-bit only)
			typeString					= REG_SZ					//@@emem Unicode nul terminated string
			};
			
			//@cmember,menum
			/* Notify change filters*/
			enum NotifyChangeFilter
			{
			notifyName					= REG_NOTIFY_CHANGE_NAME,		//@@emem Child created or deleted
			notifyAttributes			= REG_NOTIFY_CHANGE_ATTRIBUTES,	//@@emem Changed attributes
			notifyLastSet				= REG_NOTIFY_CHANGE_LAST_SET,	//@@emem Changed time stamp
			notifySecurity				= REG_NOTIFY_CHANGE_SECURITY	//@@emem Changed security
			};
			
			enum NotifyChangeFlag
			{
			changeKeyAndSubkeys			= TRUE,		//@@emem Notify on key or subkey changes
			changeSpecifiedKeyOnly		= FALSE		//@@emem Notify on specified key change only
			};
			
		#else // WIN16 only supports string key type.
			enum KeyValueTypes
			{
			typeString					= REG_SZ
			};
			
		#endif
			

			//@access Creation/Initialization

		public:

			//@cmember
			/* Constructs a Registry object.*/
			Registry();

		protected:

			//@cmember
			/* Initializes data members.*/
			virtual void Initialize( void );

		public:

		#ifdef WIN32
			//@cmember
			/* Creates key in registry (32-bit only).*/
			virtual BOOL Create( LPCTSTR	lpszSubkeyName,
					 LPCTSTR				name_of_class		= NULL,
					 CreateOptions			options				= optionsNonVolatile,
					 CreatePermissions		permissions			= permissionAllAccess,
					 LPSECURITY_ATTRIBUTES	pSecurityAttributes	= NULL,
					 CreationDisposition *	pDisposition		= NULL 
					 );
		#else
			//@cmember
			/* Creates key in registry (16-bit only).*/
			virtual BOOL Create( LPCTSTR	name_of_subkey,
					LPCTSTR					name_of_class		= NULL
					 );
		#endif
			
		// Attributes and enumerations for Registry
			
			
			//@access Operations
		public:

		#ifdef WIN32
			//@cmember
			/* Closes the current key (16 and 32-bit).*/
			virtual BOOL Close( void );
		#else	
			virtual BOOL Close( void );
		#endif //WIN32
			
		#ifdef WIN32

			//@cmember
			/* Establishes a connection with the registry (32-bit only).*/

			virtual BOOL Connect(HKEY	hKeyToOpen	= HKEY_CURRENT_USER,
						LPCTSTR	lpszComputerName	= NULL,
						BOOL bCloseKeyOnDisconnect = TRUE);

			
			//@cmember
			/* Deletes the specified key from the registry (16 and 32-bit).*/
			virtual BOOL DeleteKey( LPCTSTR lpszKeyToDelete, BOOL bRecursive = FALSE);
		#else
			virtual BOOL DeleteKey( LPCTSTR lpszKeyToDelete);	

		#endif //WIN32

		#ifdef WIN32

			//@cmember
			/* Deletes the named registry value of the current key (32-bit only).*/
			virtual BOOL DeleteValue( LPCTSTR lpszValueToDelete);
			
			//@cmember
			/* Enumerates subkeys of the currently open key (32-bit only).*/
			virtual BOOL EnumerateKeys( const DWORD dwSubkeyIndex,
						CString&	strSubkeyName);

			//@cmember
			/* Enumerates subkeys of the currently open key (32-bit only).*/
			virtual BOOL EnumerateKeys( const DWORD dwSubkeyIndex,
						CString&	strSubkeyName,
						CString&	strClassName );
			
			//@cmember
			/* Enumerates subkeys of the currently open key (32-bit only).*/
			virtual BOOL EnumerateKeys(const DWORD dwSubkeyIndex,
						LPTSTR	lpszSubkeyName,
						LPDWORD	lpdwSubkeyNameSize,
						LPTSTR	lpszClassName		= NULL,
						LPDWORD	lpdwClassNameSize	= NULL);

		#else 

			//@cmember
			/* Enumerates subkeys of the currently open key (16-bit only).*/
			virtual BOOL EnumerateKeys( const DWORD dwIndex,
						LPTSTR	   lpszBuffer,
						DWORD	   dwBufferSize);
		#endif //WIN32
			
		#ifdef WIN32


			//@cmember
			/* Enumerates values of the currently open key (32-bit only).*/
			virtual BOOL EnumerateValues( const DWORD dwValueIndex,
						CString&		strValueName,
						KeyValueTypes*	pTypeCode			= NULL,
						LPBYTE			lpbDataBuffer		= NULL,
						LPDWORD			lpdwSizeDataBuffer	= NULL);

			//@cmember
			/* Enumerates the values of the currently open key (32-bit only).*/
			virtual BOOL EnumerateValues( const DWORD dwValueIndex,
						CString&		strValueName,
						KeyValueTypes&	type_code );

			//@cmember
			/* Enumerates the values of the currently open key (32-bit only).*/
			virtual BOOL EnumerateValues( const DWORD	dwValueIndex,
						CString&			strValueName,
						KeyValueTypes&	type_code,
						LPBYTE			lpbDataBuffer,
						DWORD&			dwSizeDataBuffer );
			
			//@cmember
			/* Writes the attributes of the currently open key.*/
			virtual BOOL Flush( void );
			
			//@cmember
			/* Retrieves a REG_BINARY value (32-bit only).*/
			virtual BOOL GetBinaryValue( LPCTSTR lpszValueName, CByteArray& return_array );
			
			//@cmember
			/* Retrieves a REG_DWORD value (32-bit only).*/
			virtual BOOL GetDoubleWordValue( LPCTSTR lpszValueName, DWORD& dwReturnValue );
		#ifndef UNDER_CE
			
			//@cmember
			/* Encapsulates the RegGetSecurity() call (32-bit only).*/
			virtual BOOL GetSecurity( const SECURITY_INFORMATION security_info,
						PSECURITY_DESCRIPTOR	data_buffer,
						DWORD&					dwSizeDataBuffer);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -