include/df/registry.hpp

00001 /*
00002 
00003 Registry class
00004 
00005 To access the Windows registry database.
00006 
00007 */
00008 
00009 // access should be FO_RDONLY | FO_RDWR | FO_WRONLY | FO_CREATE
00010 
00011 class Registry : public SystemCode {
00012   _PROTECTED_:
00013 #ifdef DF_LNX
00014     String path;
00015 #else
00016     uint32 keyhand;
00017 #endif
00018     uint32 kidx;  //for Find...Key() functions
00019     uint32 vidx;  //for Find...Value() functions
00020   public:
00021     BOOL Valid;
00022 
00023     ~Registry() {if (Valid) Close();}  //Close() on delete
00024 
00025     //constructor
00026     Registry();
00027 
00028     //open/create existing key
00029     BOOL Open(uint32 key, char *subkey, int access);
00030     BOOL Open(Registry &key, char *subkey, int access);
00031 
00032     //close current key
00033     BOOL Close();
00034 
00035     //set(change) value inside current key
00036     BOOL SetValue(char *valuename, int _type, PTR data, int datasiz);
00037     BOOL SetValue(char *valuename, char *str);  //assumes REG_STR type
00038 
00039     //create value inside current key
00040     BOOL CreateValue(char *valuename, int _type, PTR data, int datasiz);
00041     BOOL CreateValue(char *valuename, char *str);  //assumes REG_STR type
00042 
00043     //get value inside current key
00044     BOOL GetValue(char *valuename, PTR data, int &datasiz);
00045 
00046     //get value into String (assumes REG_STR type)
00047     BOOL GetValue(char *valuename, String &s);
00048 
00049     //get value type inside current key
00050     BOOL GetValueType(char *valuename, int &_type);
00051 
00052     //get value size inside current key
00053     BOOL GetValueSize(char *valuename, int &_size);
00054 
00055     //delete subkey
00056     BOOL DeleteKey(char *subkey);
00057 
00058     //delete value inside current key
00059     BOOL DeleteValue(char *valuename);
00060 
00061     //enumerate subkeys/values
00062     BOOL FindFirstKey (String &_name);
00063     BOOL FindNextKey (String &_name);
00064     BOOL FindFirstValue(String &_name, int &_type);
00065     BOOL FindNextValue (String &_name, int &_type);
00066 
00067     //following are static members
00068 
00069     //delete a key/value (must be empty)
00070     static BOOL DeleteKey(uint32 key, char *subkey);
00071     static BOOL DeleteValue(uint32 key, char *subkey, char *valuename);
00072 
00073     //delete a key (including all subkeys/values)
00074     static BOOL DeleteKeyEx(uint32 key, char *subkey);
00075 
00076     //universal get/set string settings
00077     static BOOL GetValue(uint32 key, char *subkey, char *value, String &s);
00078     static BOOL SetValue(uint32 key, char *subkey, char *value, String &s);
00079 
00080     static BOOL CreateKey(uint32 key, char *subkey);
00081 };
00082 
00083 class RegistryEnumerator : public SystemCode, public Enumerator {
00084   _PROTECTED_:
00085     Registry reg;
00086     BOOL keys, first;
00087   public:
00088     //Enumerator class members
00089     BOOL First(char *);
00090     BOOL Next();
00091     BOOL Close();
00092     BOOL IsFolder();
00093     void GetRootPath(String &s);
00094 };
00095 
00096 //types
00097 #define REG_STR    1  //reg_sz
00098  #define REG_SZ REG_STR
00099 #define REG_EXPAND_STR 2
00100  #define REG_EXPAND_SZ REG_EXPAND_STR
00101 #define REG_BIN    3  //reg_binary
00102  #define REG_BINARY REG_BIN
00103 #define REG_DWORD  4  //reg_dword
00104  #define REG_UINT32 4
00105 
00106 #define HKEY_CLASSES_ROOT           ( 0x80000000 )
00107 #define HKEY_CURRENT_USER           ( 0x80000001 )
00108 #define HKEY_LOCAL_MACHINE          ( 0x80000002 )
00109 #define HKEY_USERS                  ( 0x80000003 )
00110 #define HKEY_PERFORMANCE_DATA       ( 0x80000004 )
00111 #define HKEY_CURRENT_CONFIG         ( 0x80000005 )
00112 #define HKEY_DYN_DATA               ( 0x80000006 )
00113 

Generated on Mon Mar 5 09:49:14 2007 for DigiForce by  doxygen 1.4.7