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

📄 warwin32registry.h

📁 ftpserver very good sample
💻 H
字号:
/** Wrapper class for common registry functions.*/#if WIN32#ifndef WAR_WIN32_REGISTRY_H#define WAR_WIN32_REGISTRY_H/* SYSTEM INCLUDES */#ifndef WAR_INCLUDED_WINREG_H#   define WAR_INCLUDED_WINREG_H#   include <Winreg.h>#endif#ifndef WAR_LIST_INCLUDED#   define WAR_LIST_INCLUDED#   include <list>#endif#ifndef WAR_INCLUDED_TCHAR_H#   define WAR_INCLUDED_TCHAR_H#   include <tchar.h>#endif#if WAR_CRYPTO && !defined(WAR_CRYPT_TEXT_H)#   include "WarCryptText.h"#endif/* PROJECT INCLUDES */#ifndef WAR_PATH_H#   include "WarPath.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */class WarWin32Registry;#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//* Windows NT Auth names */#define WAR_WINNT_AUTH_SERVER _T("Auth Server")#define WAR_WINNT_AUTH_SERVER_LOCAL _T("Auth Server Local")#define WAR_WINNT_AUTH_FTP_GROUP _T("FTP Group")#define WAR_WINNT_AUTH_ALLOW_ANON _T("Allow Anonymous")#define WAR_WINNT_AUTH_ANON_USER _T("Anonymous User")#define WAR_WINNT_AUTH_ANON_PASSWD _T("Anonymous Password")#define WAR_WINNT_AUTH_ANON_PWDEMAIL _T("Anonymous Require Password")#define WAR_WINNT_AUTH_GROUP _T("Auth Group")/* Windows NT run as */#define WAR_WINNT_RUN_AS_USER _T("Run as User")#define WAR_WINNT_RUN_AS_USER_PWD _T("Run as User Password")/* Shutdown value */#define WAR_WINNT_SHUTDOWN _T("Shutdown Pending")/* Startup path */#define WAR_WINNT_STARTUP_PATH _T("StartupPath")#define WAR_WINNT_PROGRAM_NAME _T("Program Name")// File Share names#define WAR_WINNT_SHARE_URL _T("Url")// Encryption support#define WAR_WINNT_REG_PKEYFILE _T("Private Key File")#define WAR_WINNT_REG_CRYPTKEY _T("Data Encryption Key")// Common registry node names#define WAR_WINNT_REG_WINNT _T("Windows NT")#define WAR_WINNT_REG_FILE_SYSTEMS _T("File Systems")#define WAR_WINNT_REG_USERS _T("Users")#define WAR_WINNT_REG_GROUPS _T("Groups")#define WAR_WINNT_REG_NAME _T("Name")#define WAR_WINNT_REG_PASSWORD _T("Password")#define WAR_WINNT_REG_FILE _T("File")#define WAR_WINNT_REG_TYPE _T("Type")#define WAR_WINNT_REG_LEVEL _T("Level")#define WAR_WINNT_REG_VALUE _T("Value")#define WAR_WINNT_REG_DEF_VALUE _T("Default Value")#define WAR_WINNT_REG_DESCRIPTION _T("Description")#define WAR_WINNT_REG_ADDRESS _T("Address")#define WAR_WINNT_REG_MODULES _T("Modules")#define WAR_WINNT_REG_ENABLE _T("Enable")#define WAR_WINNT_REG_STYLES _T("Styles")#define WAR_WINNT_REG_CLASSID _T("Class ID")#define WAR_WINNT_REG_OPTIONS _T("Options")#define WAR_WINNT_REG_DEFAULTS _T("Defaults")#define WAR_WINNT_REG_LOG_MODULES _T("Log Modules")#define WAR_WINNT_REG_EVENTS _T("Events")#define WAR_WINNT_REG_LOG_EVENTLOG _T("Eventlog")#define WAR_WINNT_REG_TAGNAME _T("Tag Name")#define WAR_WINNT_REG_FILENAME _T("File Name")#define WAR_WINNT_REG_AUTH_MODULES _T("Auth Modules")#define WAR_WINNT_REG_SERVERS _T("Servers")#define WAR_WINNT_REG_SITES _T("Sites")#define WAR_WINNT_REG_PERMISSIONS _T("Permissions")#define WAR_WINNT_REG_PROTOCOLS _T("Protocols")#define WAR_WINNT_REG_FTP _T("FTP")#define WAR_WINNT_REG_HTTP _T("HTTP")#define WAR_WINNT_REG_IP_ACCESS_LIST _T("IP Access List")#define WAR_WINNT_REG_IP_ACCESS_LIST_MODE _T("IP Access List Mode")#define WAR_WINNT_REG_PRIORITY _T("Priority")#define WAR_WINNT_REG_WEBADM _T("Webadm")#define WAR_WINNT_REG_VIRTUAL_HOST _T("Virtual Host")#define WAR_WINNT_REG_DEFAULT_PAGE _T("Default Page")#define WAR_WINNT_REG_DEFINED _T("Defined")#define WAR_WINNT_REG_MIME_TYPES _T("Mime Types")#define WAR_WINNT_USE_LOCAL_OS _T("Use Local OS")// Defined class id's#define WAR_CLSID_ROOT "d42d6418-bdec-4ee9-b1e1-7ff9466f7e3e"#define WAR_CLSID_AUTH_NT "576e475b-15b2-4df8-88ee-b73eb2c8c554"#define WAR_CLSID_SITE "116C316C-CBE6-4eaa-AFDC-7AAA3202323F"#define WAR_CLSID_LOG_COUT "317073A1-38C0-44a6-8741-850313FD4AFB"#define WAR_CLSID_LOG_FILE "DCEE537F-8002-4bde-A520-F6CD2700A118"#define WAR_CLSID_LOG_NTEVLOG "B5C1193E-7E1D-41d8-A809-D9709504642F"/****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarWin32RegistryOpenType{public:    WarWin32RegistryOpenType(const WarWin32RegistryOpenType& from)        : mReg(from.mReg), mPath(from.mPath)    {    }    WarWin32RegistryOpenType(const WarWin32Registry& reg,            const war_registrypath_t& path)            : mReg(reg), mPath(path)    {    }    const WarWin32Registry& GetReg() const    {        return mReg;    }    const war_registrypath_t& GetPath() const    {        return mPath;    }private:    const WarWin32Registry& mReg;    const war_registrypath_t mPath;};class WarWin32Registry {public:    typedef std::list<war_regstr_t>keyname_list_t;    typedef std::list<war_regstr_t>regstr_list_t;    typedef WarWin32RegistryOpenType open_t;    typedef WarWin32Registry ref_t;    // LIFECYCLE        /**    * Default constructor.    */    WarWin32Registry();            /**    * Destructor.    */    ~WarWin32Registry();        // OPERATORS    // OPERATIONS                            /** Open a registry key.       *      * Fails if it dont exist      */    void Open(const open_t& openVal,         int regMode = KEY_ALL_ACCESS)        throw(WarException);    void Open(HKEY keyRoot,         const war_registrypath_t& regPath,         int regMode = KEY_ALL_ACCESS)        throw(WarException);    /** Create a registry key    */    void Create(const open_t& openVal,        bool doFailIfNotExist = false)        throw(WarException);        void Create(HKEY keyRoot,         const war_registrypath_t& regPath,        bool doFailIfNotExist = false)        throw(WarException);    /** */    war_regstr_t GetStrValue(war_registrypath_ccstr_t valueName,        war_registrypath_ccstr_t defaultValue = NULL,        bool doFailIfNotExist = false,        bool doDecrypt = false) const        throw(WarException);    /** */    DWORD GetIntValue(war_registrypath_ccstr_t valueName,        DWORD defaultValue = 0,        bool doFailIfNotExist = false) const        throw(WarException);    regstr_list_t GetStrListValue(war_registrypath_ccstr_t valueName,        regstr_list_t& defaultValue,        bool doFailIfNotExist = false) const        throw(WarException);    /** */    void SetValue(war_registrypath_ccstr_t valueName,         const war_regstr_t& newValue, bool doEncrypt = false) const        throw(WarException);    /** */    void SetValue(war_registrypath_ccstr_t valueName,         DWORD newValue) const        throw(WarException);    /** Delete the key from the registry       *      * @param keyName Key to delete. The key pointed      *     to by the open object is deleted if this      *     is NULL.      */    void DeleteKey(war_registrypath_ccstr_t keyName = NULL);	/** Delete all values */	void DeleteAllValues() throw(WarException);    /** Delete the specified value */    void DeleteValue(war_registrypath_ccstr_t valueName) const;    /** Return a list of subkey-names */    void EnumKey(keyname_list_t& resultList);    /** Return a list of value-names */    void EnumValue(keyname_list_t& resultList);    /** Flush cached information */    void Flush();    void Rename(war_registrypath_ccstr_t newName)        throw(WarException);#if WAR_CRYPTO    /** Load the password used to encrypt/decrypt      * sensitive keys from the pam file pointed to      * by the WAR_WINNT_REG_PKEYFILE value      */    void LoadPamFile() throw(WarException);#endif // WAR_CRYPTO    void SetRootKey(HKEY newHkey)    {        mRootKey = newHkey;    }    // ACCESS    // INQUIRY    const open_t GetRef(        war_registrypath_ccstr_t SubKeyName = NULL) const;    // Get the HKEY for the open key, can be used to    // call ::Reg* operations directly    inline HKEY GetNodeKey() const    {        return mNodeKey;    }    bool IsOpen() const    {        return mNodeKey != NULL;    }    bool HaveValue(war_registrypath_ccstr_t valueName,         bool evalCrypt = false) const;    bool HaveKey(war_registrypath_ccstr_t keyName) const;        static war_registrypath_t mRootPath;protected:private:    HKEY mNodeKey;    HKEY mRootKey;    war_registrypath_t mPath;#if WAR_CRYPTO    WarCryptText mCrypto;#endif    void Reset();    Validate();#if WAR_CRYPTO    bool GetEncryptedStrValue(        war_registrypath_ccstr_t valueName,        war_regstr_t& return_val)        const throw(WarException);#endif};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif  /* WAR_WIN32_REGISTRY_H_ */#endif // WIN32

⌨️ 快捷键说明

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