1 #ifndef REG_H 2 #define REG_H 3 4 class CReg 5 { 6 public: 7 // Constructor 8 CReg(LPCSTR lpszSubKey, HKEY hRootKey=HKEY_CURRENT_USER, REGSAM regSam=KEY_ALL_ACCESS, BOOL bCreate=TRUE); 9 10 // Destructor 11 ~CReg(); 12 13 // Get the specified registry value 14 BOOL GetValue(LPCSTR lpszValueName, LPVOID lpvData, DWORD *dwBuffSize=NULL, DWORD *dwDataType=NULL); 15 BOOL GetValue(LPCSTR lpszValueName, LPSTR lpszValue, DWORD dwBalueSize); 16 // BOOL GetValue(LPCSTR lpszValueName, CString &szData, DWORD *dwDataType=NULL); 17 BOOL GetValue(LPCSTR lpszValueName, DWORD &dwData); 18 BOOL GetValue(LPCSTR lpszValueName, BOOL &bData); 19 20 // Set the specified registry value 21 BOOL SetValue(LPCSTR lpszValueName, const LPVOID lpvData, DWORD dwDataSize, DWORD dwDataType=REG_SZ); 22 BOOL SetValue(LPCSTR lpszValueName, LPCSTR lpszValue, DWORD dwDataSize=0, DWORD dwDataType=REG_SZ); 23 BOOL SetValue(LPCSTR lpszValueName, LPSTR lpszValue, DWORD dwValueSize); 24 // BOOL SetValue(LPCSTR lpszValueName, CString &szData, DWORD dwDataSize=0, DWORD dwDataType=REG_SZ); 25 BOOL SetValue(LPCSTR lpszValueName, DWORD dwData); 26 BOOL SetValue(LPCSTR lpszValueName, BOOL bData); 27 28 // Delete a value in the key 29 BOOL DeleteValue(LPCSTR lpszValueName); 30 31 // Delete all the values in the key 32 BOOL DeleteValues(); 33 34 // Delete a sub key 35 BOOL DeleteKey(LPCSTR lpszKeyName); 36 37 // Retrieve the names of the values in the key 38 // BOOL EnumerateValues(CStringArray &nszValueNames); 39 40 BOOL IsValid() {return m_hKey!=NULL;} 41 42 protected: 43 // Create a new registry key 44 LONG Create(LPCSTR lpszSubKey, HKEY hRootKey, HKEY *hKey=NULL, REGSAM regSam=NULL); 45 46 // Open the specified registry key (creates if non-existant) 47 LONG Open(LPCSTR lpszSubKey, HKEY hRootKey, HKEY *hKey=NULL, REGSAM regSam=NULL, BOOL bCreate=TRUE); 48 49 BOOL DeleteKey(HKEY hRootKey, HKEY hKey, LPCSTR szKey, LPCSTR szSubKey); 50 51 // CString m_szKey; // Name of key this object wraps 52 char m_szKey[1024]; // Name of key this object wraps 53 HKEY m_hRootKey; // Root key of the wrapped key 54 HKEY m_hKey; // Key generated by Open/Create 55 56 }; 57 58 #endif 59