registry.h

Go to the documentation of this file.
00001 // $Id: registry.h 751 2006-03-31 15:43:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 /*
00099 
00100     registry.h
00101 
00102     Interface to the system registry, which provides a container for storing information about
00103     the app.  Under Windows NT / Windows 95 this is placed in the Registry, under Windows 3.1
00104     it is placed in an .INI file.
00105 */
00106 
00107 #ifndef REGISTRY_H
00108 #define REGISTRY_H 
00109 
00110 
00111 #define SAVE_PREFS_TO_REGISTRY
00112 
00113 // Initialises our registry entries.
00114 BOOL InitRegistry();
00115 BOOL DeInitRegistry();
00116 
00117 // This string is our special Application identifier.
00118 extern TCHAR szCamelotAppRegistryID[];
00119 
00120 // This holds the full path to our executable.
00121 extern TCHAR szCamelotExePath[_MAX_PATH];
00122 
00123 // This handle is maintained by REGISTRY.CPP.  All application state info should be
00124 // stored under this key.
00125 extern HKEY hAppStateRegKey;
00126 
00127 // These create or open a registry key, and set a value within it.
00128 HKEY CreateRegKey(HKEY hKey, LPCTSTR lpcszSubKey, LPTSTR lpszClass = NULL);
00129 HKEY OpenRegKey(HKEY hKey, LPCTSTR lpcszSubKey);
00130 HKEY OpenRegKeyReadOnly(HKEY hKey, LPCTSTR lpcszSubKey);
00131 BOOL CloseRegKey(HKEY hKey);
00132 BOOL GetRegValue(HKEY hKey, LPTSTR szValueName, LPDWORD pdwType,
00133                  LPVOID pvBuf, LPDWORD pdwBufSize);
00134 BOOL SetRegValue(HKEY hKey, LPCTSTR lpcszValueName, DWORD dwType,
00135                  const VOID* pcData, DWORD cbData);
00136 
00137 // Useful variations on the main functions
00138 BOOL    SetRegDword(HKEY hKey, LPCTSTR lpcszValueName, DWORD Value);
00139 BOOL    SetRegInt(HKEY hKey, LPCTSTR lpcszValueName, INT32 Value);
00140 BOOL    SetRegBool(HKEY hKey, LPCTSTR lpcszValueName, BOOL Value);
00141 BOOL    SetRegString(HKEY hKey, LPCTSTR lpcszValueName, String_256* str);
00142 BOOL    SetRegString(HKEY hKey, LPCTSTR lpcszValueName, TCHAR * str);
00143 
00144 // These are much more convenient, but don't have very sophisticated error reporting.
00145 INT32       GetRegInt(HKEY hKey, LPCTSTR szValueName);
00146 BOOL    GetRegBool(HKEY hKey, LPCTSTR szValueName);
00147 DWORD   GetRegDword(HKEY hKey, LPCTSTR szValueName);
00148 BOOL    GetRegString(HKEY hKey, LPCTSTR szValueName, String_256* pOut);
00149 BOOL    GetRegString(HKEY hKey, LPCTSTR szValueName, TCHAR * str, UINT32 str_len = 256);
00150 
00151 // This deletes the given sub-key of hKey.
00152 BOOL DeleteRegKey(HKEY hKey, LPCTSTR szSubKey);
00153 // This deletes the given sub-key and any sub-keys of that
00154 BOOL DeleteRegKeyAndSubKeys(HKEY hKey, LPCTSTR szSubKey);
00155 
00156 // Useful general functions
00157 String_256 GetProgramNameRegistryKey();
00158 BOOL CheckForRegistryEntry(TCHAR * SubKeyName);
00159 BOOL ConvertCLSIDToString(const CLSID& ID, StringBase* const pString);
00160 
00161 /****************************************************************************
00162 
00163 >   class SaveRegistryEntries : public CC_CLASS_MEMDUMP
00164 
00165     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00166     Created:    18/02/97
00167     Purpose:    This class can be used for saving a list of items into the
00168                 registry.
00169 
00170 ****************************************************************************/
00171 
00172 class SaveRegistryEntries : public CC_CLASS_MEMDUMP
00173 {
00174     // Declare the class for memory tracking
00175     CC_DECLARE_MEMDUMP(SaveRegistryEntries);
00176 public:
00177     SaveRegistryEntries() { m_hRegKey = NULL; m_Counter = 0; };
00178     ~SaveRegistryEntries();
00179 
00180 public:     // Scanning through a set of particular files in a directory
00181     BOOL StartSaving(String_256 *pKeySpecifier, HKEY hSubKey = hAppStateRegKey);
00182     BOOL SaveNextEntry(String_256 *pNextName);
00183     BOOL StopSaving();
00184 
00185     HKEY GetRegKey() { return m_hRegKey; }
00186 
00187 private:    // Private data
00188     HKEY m_hRegKey; // the key we are saving under
00189     INT32   m_Counter;  // a counter of the items saved
00190 };
00191 
00192 /****************************************************************************
00193 
00194 >   class LoadRegistryEntries : public CC_CLASS_MEMDUMP
00195 
00196     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00197     Created:    18/02/97
00198     Purpose:    This class can be used for loading a list of items into the
00199                 registry.
00200 
00201 ****************************************************************************/
00202 
00203 class LoadRegistryEntries : public CC_CLASS_MEMDUMP
00204 {
00205     // Declare the class for memory tracking
00206     CC_DECLARE_MEMDUMP(LoadRegistryEntries);
00207 public:
00208     LoadRegistryEntries() { m_hRegKey = NULL; m_Counter = 0; };
00209     ~LoadRegistryEntries();
00210 
00211 public:     // Scanning through a set of particular files in a directory
00212     BOOL StartLoading(String_256 *pKeySpecifier, HKEY hSubKey = hAppStateRegKey);
00213     BOOL LoadNextEntry(String_256 *pNextName);
00214     BOOL StopLoading();
00215 
00216     HKEY GetRegKey() { return m_hRegKey; }
00217     INT32  GetNumberOfItemsLoaded() { return m_Counter; }
00218 
00219 private:    // Private data
00220     HKEY m_hRegKey; // the key we are saving under
00221     INT32   m_Counter;  // a counter of the items saved
00222 };
00223 
00224 
00225 extern const String_8 NullString;
00226 
00227 /********************************************************************************************
00228 
00229 >   class Registry
00230 
00231     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00232     Created:    09/06/97
00233 
00234     Purpose:    There is more than one registry you know. 
00235                 At present, this class is only ever the local one (honest)
00236 
00237 ********************************************************************************************/
00238 class ClassCategoryProbe;
00239 
00240 class Registry
00241 {
00242 public:
00243 //  static String_256 GetProgramNameRegistryKey();
00244 
00245 //  Registry();
00246 //  BOOL InitRegistry();
00247 
00248 //  BOOL DeInitRegistry()
00249 //  ~Registry();
00250 
00251 //  BOOL CheckForRegistryEntry(const StringBase& SubKeyName);
00252 //  BOOL UpdateInstanceVersion( const StringBase& ThisVersion,
00253 //                              DWORD dwThisBuildMajor, DWORD dwThisBuildMinor);
00254 
00255     BOOL InitializeProbe(ClassCategoryProbe& Probe);
00256 private:
00257 };
00258 
00259 
00260 /********************************************************************************************
00261 
00262 >   class RegistryEntry
00263 
00264     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00265     Created:    09/06/97
00266 
00267     Purpose:    Represents an entry in the registry consisting of a key, subkeys, and some
00268                 values. 
00269 
00270     Notes:      It can't be instantiated, but derived classes should provide implementation
00271                 to initialize the HKEY held herein.
00272 
00273     See Also:   ClassRegistryEntry
00274 
00275 ********************************************************************************************/
00276 class RegistryEntry
00277 {
00278 public:
00279     virtual ~RegistryEntry();
00280 
00281     virtual BOOL GetValue(const StringBase& ValueName, StringBase* const pValue);
00282     virtual BOOL GetEmbeddedEntry(const StringBase& Name, RegistryEntry* const pEntry) const;
00283 
00284 protected:
00285     RegistryEntry(HKEY hKey = 0) : m_hKey(hKey) {}
00286     RegistryEntry(const RegistryEntry&);
00287 
00288     
00289 protected:
00290     HKEY    m_hKey;
00291 };
00292 
00293 
00294 
00295 /********************************************************************************************
00296 
00297 >   class ClassRegistryEntry : public RegistryEntry
00298 
00299     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00300     Created:    09/06/97
00301 
00302     Purpose:    Represents an entry in CLSID section of the registry, consisting of a key, 
00303                 subkeys, and some values.
00304 
00305 ********************************************************************************************/
00306 class ClassRegistryEntry : public RegistryEntry
00307 {
00308 public:
00309     BOOL InitFromCLSID(const CLSID& ClassID);
00310 
00311 private:
00312     static const String_8   s_CLSIDString;
00313 };
00314 
00315 
00316 /********************************************************************************************
00317 
00318 >   class VersionIndependentProgID : public RegistryEntry
00319 
00320     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00321     Created:    09/06/97
00322 
00323     Purpose:    Represents the VersionIndependentProgID key in a registry.
00324                 Saves us some typing really.
00325 
00326 ********************************************************************************************/
00327 class VersionIndependentProgID : public RegistryEntry
00328 {
00329 public:
00330     VersionIndependentProgID(const ClassRegistryEntry& CLSIDEntry);
00331 
00332     BOOL GetName(StringBase* const pName);
00333 
00334 private:
00335     static const String_32 s_KeyName;
00336 };
00337 
00338 
00339 /********************************************************************************************
00340 
00341 >   class ClassCategoryProbe //: public RegistryProbe
00342 
00343     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00344     Created:    09/06/97
00345 
00346     Purpose:    Allows us to whizz through a component category picking out all the registry
00347                 entries for it.
00348                 At present, this class is only ever associated with the local registry
00349 
00350 ********************************************************************************************/
00351 #pragma warning( disable : 4091 )   // otherwise it wants <comcat.h> included
00352 typedef CATID;
00353 #pragma warning( default : 4091 )
00354 struct ICatInformation;
00355 struct IEnumCLSID;
00356 
00357 class ClassCategoryProbe //: public RegistryProbe
00358 {
00359 public:
00360     ClassCategoryProbe();
00361     ClassCategoryProbe(const ClassCategoryProbe& OtherProbe);
00362     ~ClassCategoryProbe();
00363 
00364     BOOL Init();
00365 
00366     BOOL GetNextEntry(ClassRegistryEntry* const pEntry);
00367     BOOL IsLast() const;
00368 
00369 protected:
00370     // Implementation
00371     BOOL GetNextCLSID(CLSID* const pNextCLSID);
00372     ICatInformation* CreateCatInformer();
00373 
00374     virtual const CATID& GetCategoryID() const = 0;
00375 
00376 private:
00377     IEnumCLSID*     m_pEnumCLSID;
00378     CLSID           m_NextCLSIDToReturn;
00379 
00380     static const String_256 s_CLSIDKey;
00381 };
00382 
00383 
00384 Registry* GetLocalRegistry();
00385 
00386 
00387 inline RegistryEntry::~RegistryEntry()
00388 {
00389     CloseRegKey(m_hKey);
00390 }
00391 
00392 inline RegistryEntry::RegistryEntry(const RegistryEntry&)
00393 {   
00394     TRACE( _T("RegistryEntry - Copy constructor not implemented\n"));
00395 }
00396 
00397 
00398 #endif  // REGISTRY_H

Generated on Sat Nov 10 03:48:50 2007 for Camelot by  doxygen 1.4.4