xref: /aoo42x/main/registry/inc/registry/registry.hxx (revision f006f9b4)
15a5f4a75SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35a5f4a75SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45a5f4a75SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55a5f4a75SAndrew Rist  * distributed with this work for additional information
65a5f4a75SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75a5f4a75SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85a5f4a75SAndrew Rist  * "License"); you may not use this file except in compliance
95a5f4a75SAndrew Rist  * with the License.  You may obtain a copy of the License at
105a5f4a75SAndrew Rist  *
115a5f4a75SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
125a5f4a75SAndrew Rist  *
135a5f4a75SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145a5f4a75SAndrew Rist  * software distributed under the License is distributed on an
155a5f4a75SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165a5f4a75SAndrew Rist  * KIND, either express or implied.  See the License for the
175a5f4a75SAndrew Rist  * specific language governing permissions and limitations
185a5f4a75SAndrew Rist  * under the License.
195a5f4a75SAndrew Rist  *
205a5f4a75SAndrew Rist  *************************************************************/
215a5f4a75SAndrew Rist 
225a5f4a75SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _REGISTRY_REGISTRY_HXX_
25cdf0e10cSrcweir #define _REGISTRY_REGISTRY_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <registry/regtype.h>
28cdf0e10cSrcweir #include <rtl/ustring.hxx>
29*f006f9b4SDamjan Jovanovic #include "registry/registrydllapi.h"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifdef __cplusplus
32cdf0e10cSrcweir extern "C" {
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir 
35cdf0e10cSrcweir /** specifies a collection of function pointers which represents the complete registry C-API.
36cdf0e10cSrcweir 
37cdf0e10cSrcweir     This funtions pointers are used by the C++ wrapper to call the C-API.
38cdf0e10cSrcweir */
39cdf0e10cSrcweir struct Registry_Api
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 	void	  	(REGISTRY_CALLTYPE *acquire) 			(RegHandle);
42cdf0e10cSrcweir 	void	  	(REGISTRY_CALLTYPE *release) 			(RegHandle);
43cdf0e10cSrcweir 	sal_Bool 	(REGISTRY_CALLTYPE *isReadOnly)			(RegHandle);
44cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *openRootKey)		(RegHandle, RegKeyHandle*);
45cdf0e10cSrcweir 	RegError	(REGISTRY_CALLTYPE *getName)			(RegHandle, rtl_uString**);
46cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *createRegistry)		(rtl_uString*, RegHandle*);
47cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *openRegistry)		(rtl_uString*, RegHandle*, RegAccessMode);
48cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *closeRegistry)		(RegHandle);
49cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *destroyRegistry)	(RegHandle,	rtl_uString*);
50cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *loadKey)			(RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*);
51cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *saveKey)			(RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*);
52cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *mergeKey)			(RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*, sal_Bool, sal_Bool);
53cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *dumpRegistry) 		(RegHandle, RegKeyHandle);
54cdf0e10cSrcweir 	void	  	(REGISTRY_CALLTYPE *acquireKey) 	  	(RegKeyHandle);
55cdf0e10cSrcweir 	void	  	(REGISTRY_CALLTYPE *releaseKey) 	  	(RegKeyHandle);
56cdf0e10cSrcweir 	sal_Bool 	(REGISTRY_CALLTYPE *isKeyReadOnly)	  	(RegKeyHandle);
57cdf0e10cSrcweir 	RegError  	(REGISTRY_CALLTYPE *getKeyName)			(RegKeyHandle, rtl_uString**);
58cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *createKey)			(RegKeyHandle, rtl_uString*, RegKeyHandle*);
59cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *openKey)			(RegKeyHandle, rtl_uString*, RegKeyHandle*);
60cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *openSubKeys)		(RegKeyHandle, rtl_uString*, RegKeyHandle**, sal_uInt32*);
61cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *closeSubKeys)		(RegKeyHandle*, sal_uInt32);
62cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *deleteKey)			(RegKeyHandle, rtl_uString*);
63cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *closeKey)			(RegKeyHandle);
64cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *setValue)			(RegKeyHandle, rtl_uString*, RegValueType, RegValue, sal_uInt32);
65cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *setLongListValue)	(RegKeyHandle, rtl_uString*, sal_Int32*, sal_uInt32);
66cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *setStringListValue)	(RegKeyHandle, rtl_uString*, sal_Char**, sal_uInt32);
67cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *setUnicodeListValue)(RegKeyHandle, rtl_uString*, sal_Unicode**, sal_uInt32);
68cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *getValueInfo)		(RegKeyHandle, rtl_uString*, RegValueType*, sal_uInt32*);
69cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *getValue)			(RegKeyHandle, rtl_uString*, RegValue);
70cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *getLongListValue)	(RegKeyHandle, rtl_uString*, sal_Int32**, sal_uInt32*);
71cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *getStringListValue)	(RegKeyHandle, rtl_uString*, sal_Char***, sal_uInt32*);
72cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *getUnicodeListValue)(RegKeyHandle, rtl_uString*, sal_Unicode***, sal_uInt32*);
73cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *freeValueList)		(RegValueType, RegValue, sal_uInt32);
74cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *createLink) 		(RegKeyHandle, rtl_uString*, rtl_uString*);
75cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *deleteLink)			(RegKeyHandle, rtl_uString*);
76cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *getKeyType)			(RegKeyHandle, rtl_uString*, RegKeyType*);
77cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *getLinkTarget)		(RegKeyHandle, rtl_uString*, rtl_uString**);
78cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *getResolvedKeyName)	(RegKeyHandle, rtl_uString*, sal_Bool, rtl_uString**);
79cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *getKeyNames)		(RegKeyHandle, rtl_uString*, rtl_uString***, sal_uInt32*);
80cdf0e10cSrcweir 	RegError 	(REGISTRY_CALLTYPE *freeKeyNames)		(rtl_uString**, sal_uInt32);
81cdf0e10cSrcweir };
82cdf0e10cSrcweir 
83cdf0e10cSrcweir /** the API initialization function.
84cdf0e10cSrcweir */
85*f006f9b4SDamjan Jovanovic REGISTRY_DLLPUBLIC Registry_Api* REGISTRY_CALLTYPE initRegistry_Api(void);
86cdf0e10cSrcweir 
87cdf0e10cSrcweir #ifdef __cplusplus
88cdf0e10cSrcweir }
89cdf0e10cSrcweir #endif
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir class RegistryKey;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir //-----------------------------------------------------------------------------
95cdf0e10cSrcweir 
96cdf0e10cSrcweir /** The Registry provides the functionality to read and write information in a registry file.
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	The class is implemented inline and use a C-Api.
99cdf0e10cSrcweir */
100cdf0e10cSrcweir class Registry
101cdf0e10cSrcweir {
102cdf0e10cSrcweir public:
103cdf0e10cSrcweir 	/** Default constructor.
104cdf0e10cSrcweir 	 */
105cdf0e10cSrcweir 	inline Registry();
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	/// Copy constructcor
108cdf0e10cSrcweir 	inline Registry(const Registry& toCopy);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	/// Destructor. The Destructor close the registry if it is open.
111cdf0e10cSrcweir 	inline ~Registry();
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	/// Assign operator
114cdf0e10cSrcweir 	inline Registry& operator = (const Registry& toAssign);
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 	/// checks if the registry points to a valid registry data file.
117cdf0e10cSrcweir 	inline sal_Bool	isValid() const;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	/**	returns the access mode of the registry.
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 		@return	TRUE if the access mode is readonly else FALSE.
122cdf0e10cSrcweir 	*/
123cdf0e10cSrcweir 	inline sal_Bool 	isReadOnly() const;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	/**	opens the root key of the registry.
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 		@param 	rRootKey reference to a RegistryKey which is filled with the rootkey.
128cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
129cdf0e10cSrcweir 	*/
130cdf0e10cSrcweir 	inline RegError openRootKey(RegistryKey& rRootKey);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	/// returns the name of the current registry data file.
133cdf0e10cSrcweir 	inline ::rtl::OUString getName();
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	/**	creates a new registry with the specified name and creates a root key.
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 		@param	registryName specifies the name of the new registry.
138cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
139cdf0e10cSrcweir 	*/
140cdf0e10cSrcweir 	inline RegError create(const ::rtl::OUString& registryName);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	/**	opens a registry with the specified name.
143cdf0e10cSrcweir 
144cdf0e10cSrcweir         If the registry already points to a valid registry, the old registry will be closed.
145cdf0e10cSrcweir 		@param	registryName specifies a registry name.
146cdf0e10cSrcweir 		@param 	accessMode specifies the access mode for the registry, REG_READONLY or REG_READWRITE.
147cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
148cdf0e10cSrcweir 	*/
149cdf0e10cSrcweir 	inline RegError open(const ::rtl::OUString& registryName,
150cdf0e10cSrcweir 					   	 RegAccessMode accessMode);
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	/// closes explicitly the current registry data file.
153cdf0e10cSrcweir 	inline RegError close();
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	/**	destroys a registry.
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		@param registryName specifies a registry name, if the name is an empty string the registry
158cdf0e10cSrcweir                             itselfs will be destroyed.
159cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
160cdf0e10cSrcweir 	*/
161cdf0e10cSrcweir 	inline RegError destroy(const ::rtl::OUString& registryName);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	/**	loads registry information from a specified file and save it under the
164cdf0e10cSrcweir 		specified keyName.
165cdf0e10cSrcweir 
166cdf0e10cSrcweir         @param	rKey references a currently open key. The key which should store the registry information
167cdf0e10cSrcweir                      is a subkey of this key.
168cdf0e10cSrcweir         @param	keyName	specifies the name of the key which stores the registry information. If keyName is
169cdf0e10cSrcweir                         is an empty string the registry information will be saved under the key specified
170cdf0e10cSrcweir                         by rKey.
171cdf0e10cSrcweir 		@param	regFileName	specifies the file containing the registry information.
172cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
173cdf0e10cSrcweir 	*/
174cdf0e10cSrcweir 	inline RegError loadKey(RegistryKey& rKey,
175cdf0e10cSrcweir 				  			 const ::rtl::OUString& keyName,
176cdf0e10cSrcweir 				  			 const ::rtl::OUString& regFileName);
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	/**	saves the registry information of the specified key and all subkeys and save
179cdf0e10cSrcweir 		it in the specified file.
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 		@param	rKey references a currently open key. The key which information is saved by this
182cdf0e10cSrcweir                      function is a subkey of this key.
183cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which information should be stored.
184cdf0e10cSrcweir                         If keyName is an empty string the registry information under the key specified
185cdf0e10cSrcweir                         by rKey is saved in the specified file.
186cdf0e10cSrcweir 		@param	regFileName	specifies the file containing the registry information.
187cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
188cdf0e10cSrcweir 	*/
189cdf0e10cSrcweir 	inline RegError saveKey(RegistryKey& rKey,
190cdf0e10cSrcweir 				  			 const ::rtl::OUString& keyName,
191cdf0e10cSrcweir 				  			 const ::rtl::OUString& regFileName);
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 	/**	merges the registry information of the specified key with the registry
194cdf0e10cSrcweir 		information of the specified file.
195cdf0e10cSrcweir 
196cdf0e10cSrcweir         All existing keys will be extended and existing key values will be overwritten.
197cdf0e10cSrcweir 		@param	rKey references a currently open key. The key which information is merged by this
198cdf0e10cSrcweir                      function is a subkey of this key
199cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which will be merged.
200cdf0e10cSrcweir                         If keyName is an empty string the registry information under the key specified
201cdf0e10cSrcweir                         by rKey is merged with the information from the specified file.
202cdf0e10cSrcweir 		@param	regFileName	specifies the file containing the registry information.
203cdf0e10cSrcweir 		@param	bWarnings if TRUE the function returns an error if a key already exists.
204cdf0e10cSrcweir 		@param	bReport if TRUE the function reports warnings on stdout if a key already exists.
205cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code. If it returns an error the registry will
206cdf0e10cSrcweir                 restore the state before merging.
207cdf0e10cSrcweir 	*/
208cdf0e10cSrcweir 	inline RegError mergeKey(RegistryKey& rKey,
209cdf0e10cSrcweir 				   			 const ::rtl::OUString& keyName,
210cdf0e10cSrcweir 				   			 const ::rtl::OUString& regFileName,
211cdf0e10cSrcweir 							 sal_Bool bWarnings = sal_False,
212cdf0e10cSrcweir 				   			 sal_Bool bReport = sal_False);
213cdf0e10cSrcweir 
214cdf0e10cSrcweir     /**	This function reports the complete registry information of a key and all of its subkeys.
215cdf0e10cSrcweir 
216cdf0e10cSrcweir         All information which are available (keynames, value types, values, ...)
217cdf0e10cSrcweir         will be printed to stdout for report issues only.
218cdf0e10cSrcweir 	    @param	rKey references a currently open key which content will be reported.
219cdf0e10cSrcweir 	    @return	REG_NO_ERROR if succeeds else an error code.
220cdf0e10cSrcweir     */
221cdf0e10cSrcweir 	inline RegError dumpRegistry(RegistryKey& rKey);
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 	friend class RegistryKey;
224cdf0e10cSrcweir 	friend class RegistryKeyArray;
225cdf0e10cSrcweir 	friend class RegistryKeyNames;
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     /// returns the used registry Api.
getApi()228cdf0e10cSrcweir 	const Registry_Api* getApi() { return m_pApi; }
229cdf0e10cSrcweir protected:
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     /// stores the used and initialized registry Api.
232cdf0e10cSrcweir 	const Registry_Api*							 m_pApi;
233cdf0e10cSrcweir     /// stores the handle of the underlying registry file on which most of the functions work.
234cdf0e10cSrcweir 	RegHandle									 m_hImpl;
235cdf0e10cSrcweir };
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 
238cdf0e10cSrcweir //-----------------------------------------------------------------------------
239cdf0e10cSrcweir 
240cdf0e10cSrcweir /** RegistryKeyArray represents an array of open keys.
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 	RegistryKeyArray is a helper class to work with an array of keys.
243cdf0e10cSrcweir */
244cdf0e10cSrcweir class RegistryKeyArray
245cdf0e10cSrcweir {
246cdf0e10cSrcweir public:
247cdf0e10cSrcweir 	/// Default constructor
248cdf0e10cSrcweir 	inline RegistryKeyArray();
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 	/// Destructor, all subkeys will be closed.
251cdf0e10cSrcweir 	inline ~RegistryKeyArray();
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 	/// returns the open key specified by index.
254cdf0e10cSrcweir 	inline RegistryKey getElement(sal_uInt32 index);
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 	/// returns the length of the array.
257cdf0e10cSrcweir 	inline sal_uInt32 getLength();
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	friend class RegistryKey;
260cdf0e10cSrcweir protected:
261cdf0e10cSrcweir     /** sets the data of the key array.
262cdf0e10cSrcweir 
263cdf0e10cSrcweir         @param registry specifies the registry files where the keys are located.
264cdf0e10cSrcweir         @param phKeys points to an array of open keys.
265cdf0e10cSrcweir         @param length specifies the length of the array specified by phKeys.
266cdf0e10cSrcweir      */
267cdf0e10cSrcweir 	inline void setKeyHandles(Registry& registry, RegKeyHandle* phKeys, sal_uInt32 length);
268cdf0e10cSrcweir     /// close all subkeys
269cdf0e10cSrcweir 	inline RegError closeKeyHandles();
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     /// stores the number of open subkeys, the number of elements.
272cdf0e10cSrcweir 	sal_uInt32 	   	m_length;
273cdf0e10cSrcweir     /// stores an array of open subkeys.
274cdf0e10cSrcweir 	RegKeyHandle*	m_phKeys;
275cdf0e10cSrcweir     /// stores the handle to the registry file where the appropriate keys are located.
276cdf0e10cSrcweir 	Registry		m_registry;
277cdf0e10cSrcweir };
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 
280cdf0e10cSrcweir /** RegistryKeyNames represents an array of key names.
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 	RegistryKeyNames is a helper class to work with an array of key names.
283cdf0e10cSrcweir */
284cdf0e10cSrcweir class RegistryKeyNames
285cdf0e10cSrcweir {
286cdf0e10cSrcweir public:
287cdf0e10cSrcweir 	/// Default constructor
288cdf0e10cSrcweir 	inline RegistryKeyNames();
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 	/// Destructor, the internal array with key names will be deleted.
291cdf0e10cSrcweir 	inline ~RegistryKeyNames();
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 	/// returns the name of the key sepecified by index.
294cdf0e10cSrcweir 	inline ::rtl::OUString getElement(sal_uInt32 index);
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 	/// returns the length of the array.
297cdf0e10cSrcweir 	inline sal_uInt32 getLength();
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 	friend class RegistryKey;
300cdf0e10cSrcweir protected:
301cdf0e10cSrcweir     /** sets the data of the array.
302cdf0e10cSrcweir 
303cdf0e10cSrcweir         @param registry specifies the registry files where the keys are located.
304cdf0e10cSrcweir         @param pKeyNames points to an array of key names.
305cdf0e10cSrcweir         @param length specifies the length of the array specified by pKeyNames.
306cdf0e10cSrcweir      */
307cdf0e10cSrcweir 	inline void setKeyNames(Registry& registry, rtl_uString** pKeyNames, sal_uInt32 length);
308cdf0e10cSrcweir     /// delete the array of key names.
309cdf0e10cSrcweir 	inline RegError freeKeyNames();
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     /// stores the number of key names, the number of elements.
312cdf0e10cSrcweir 	sal_uInt32 		m_length;
313cdf0e10cSrcweir     /// stores an array of key names.
314cdf0e10cSrcweir 	rtl_uString**	m_pKeyNames;
315cdf0e10cSrcweir     /// stores the handle to the registry file where the appropriate keys are located.
316cdf0e10cSrcweir 	Registry		m_registry;
317cdf0e10cSrcweir };
318cdf0e10cSrcweir 
319cdf0e10cSrcweir //-----------------------------------------------------------------------------
320cdf0e10cSrcweir 
321cdf0e10cSrcweir /** RegistryValueList represents a value list of the specified type.
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 	RegistryValueList is a helper class to work with a list value.
324cdf0e10cSrcweir */
325cdf0e10cSrcweir template<class ValueType>
326cdf0e10cSrcweir class RegistryValueList
327cdf0e10cSrcweir {
328cdf0e10cSrcweir public:
329cdf0e10cSrcweir 	/// Default constructor
RegistryValueList()330cdf0e10cSrcweir 	RegistryValueList()
331cdf0e10cSrcweir 		: m_length(0)
332cdf0e10cSrcweir 		, m_pValueList(NULL)
333cdf0e10cSrcweir 		, m_valueType(RG_VALUETYPE_NOT_DEFINED)
334cdf0e10cSrcweir 		{}
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 	/// Destructor, the internal value list will be freed.
~RegistryValueList()337cdf0e10cSrcweir 	~RegistryValueList()
338cdf0e10cSrcweir 	{
339cdf0e10cSrcweir 		if (m_pValueList)
340cdf0e10cSrcweir 		{
341cdf0e10cSrcweir 			m_registry.getApi()->freeValueList(m_valueType, m_pValueList, m_length);
342cdf0e10cSrcweir 		}
343cdf0e10cSrcweir 	}
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 	/// returns the value of the list specified by index.
getElement(sal_uInt32 index)346cdf0e10cSrcweir 	ValueType getElement(sal_uInt32 index)
347cdf0e10cSrcweir 	{
348cdf0e10cSrcweir 		if (m_registry.isValid() && index < m_length)
349cdf0e10cSrcweir 		{
350cdf0e10cSrcweir 			return m_pValueList[index];
351cdf0e10cSrcweir 		} else
352cdf0e10cSrcweir 		{
353cdf0e10cSrcweir 			return 0;
354cdf0e10cSrcweir 		}
355cdf0e10cSrcweir 	}
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 	/// returns the length of the list.
getLength()358cdf0e10cSrcweir 	sal_uInt32 getLength()
359cdf0e10cSrcweir 	{
360cdf0e10cSrcweir 		return m_length;
361cdf0e10cSrcweir 	}
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 	friend class RegistryKey;
364cdf0e10cSrcweir protected:
365cdf0e10cSrcweir     /** sets the data of the value list.
366cdf0e10cSrcweir 
367cdf0e10cSrcweir         @param registry specifies the registry files where the appropriate key is located.
368cdf0e10cSrcweir         @param valueType specifies the type of the list values.
369cdf0e10cSrcweir         @param pValueList points to a value list.
370cdf0e10cSrcweir         @param length specifies the length of the list.
371cdf0e10cSrcweir      */
setValueList(Registry & registry,RegValueType valueType,ValueType * pValueList,sal_uInt32 length)372cdf0e10cSrcweir 	void setValueList(Registry& registry, RegValueType valueType,
373cdf0e10cSrcweir 					  ValueType* pValueList, sal_uInt32 length)
374cdf0e10cSrcweir 	{
375cdf0e10cSrcweir 		m_length = length;
376cdf0e10cSrcweir 		m_pValueList = pValueList;
377cdf0e10cSrcweir 		m_valueType = valueType;
378cdf0e10cSrcweir 		m_registry = registry;
379cdf0e10cSrcweir 	}
380cdf0e10cSrcweir 
381cdf0e10cSrcweir     /// stores the length of the list, the number of elements.
382cdf0e10cSrcweir 	sal_uInt32 		m_length;
383cdf0e10cSrcweir     /// stores the value list.
384cdf0e10cSrcweir 	ValueType*		m_pValueList;
385cdf0e10cSrcweir     /// stores the type of the list elements
386cdf0e10cSrcweir 	RegValueType	m_valueType;
387cdf0e10cSrcweir     /** stores the handle to the registry file where the appropriate key to this
388cdf0e10cSrcweir         value is located.
389cdf0e10cSrcweir     */
390cdf0e10cSrcweir 	Registry		m_registry;
391cdf0e10cSrcweir };
392cdf0e10cSrcweir 
393cdf0e10cSrcweir //-----------------------------------------------------------------------------
394cdf0e10cSrcweir 
395cdf0e10cSrcweir /** RegistryKey reads or writes information of the underlying key in a registry.
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 	Class is inline and use a load on call C-Api.
398cdf0e10cSrcweir */
399cdf0e10cSrcweir class RegistryKey
400cdf0e10cSrcweir {
401cdf0e10cSrcweir public:
402cdf0e10cSrcweir 	/// Default constructor
403cdf0e10cSrcweir 	inline RegistryKey();
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 	/// Copy constructor
406cdf0e10cSrcweir 	inline RegistryKey(const RegistryKey& toCopy);
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 	/// Destructor, close the key if it references an open one.
409cdf0e10cSrcweir 	inline ~RegistryKey();
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 	/// Assign operator
412cdf0e10cSrcweir 	inline RegistryKey& operator = (const RegistryKey& toAssign);
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 	/// checks if the key points to a valid registry key.
415cdf0e10cSrcweir 	inline sal_Bool	isValid() const;
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 	/**	returns the access mode of the key.
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 		@return	TRUE if access mode is read only else FALSE.
420cdf0e10cSrcweir 	*/
421cdf0e10cSrcweir 	inline sal_Bool 	isReadOnly() const;
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 	/// returns the full qualified name of the key beginning with the rootkey.
424cdf0e10cSrcweir 	inline ::rtl::OUString getName();
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	/**	creates a new key or opens a key if the specified key already exists.
427cdf0e10cSrcweir 
428cdf0e10cSrcweir         The specified keyname is relativ to this key.
429cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which will be opened or created.
430cdf0e10cSrcweir 		@param	rNewKey	references a RegistryKey which will be filled with the new or open key.
431cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
432cdf0e10cSrcweir 	*/
433cdf0e10cSrcweir 	inline RegError createKey(const ::rtl::OUString& keyName,
434cdf0e10cSrcweir 							  RegistryKey& rNewKey);
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 	/**	opens the specified key.
437cdf0e10cSrcweir 
438cdf0e10cSrcweir         The specified keyname is relativ to this key.
439cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which will be opened.
440cdf0e10cSrcweir 		@param	rOpenKey references a RegistryKey which will be filled with the open key.
441cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
442cdf0e10cSrcweir 	*/
443cdf0e10cSrcweir 	inline RegError openKey(const ::rtl::OUString& keyName,
444cdf0e10cSrcweir 				  			RegistryKey& rOpenKey);
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 	/**	opens all subkeys of the specified key.
447cdf0e10cSrcweir 
448cdf0e10cSrcweir         The specified keyname is relativ to this key.
449cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which subkeys will be opened.
450cdf0e10cSrcweir 		@param	rSubKeys reference a RegistryKeyArray which will be filled with the open subkeys.
451cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
452cdf0e10cSrcweir 	*/
453cdf0e10cSrcweir 	inline RegError openSubKeys(const ::rtl::OUString& keyName,
454cdf0e10cSrcweir 					  	  		RegistryKeyArray& rSubKeys);
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 	/**	returns an array with the names of all subkeys of the specified key.
457cdf0e10cSrcweir 
458cdf0e10cSrcweir         The specified keyname is relativ to this key.
459cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which subkey names will be returned.
460cdf0e10cSrcweir 		@param	rSubKeyNames reference a RegistryKeyNames array which will be filled with the subkey names.
461cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
462cdf0e10cSrcweir 	*/
463cdf0e10cSrcweir 	inline RegError getKeyNames(const ::rtl::OUString& keyName,
464cdf0e10cSrcweir 					  	  		RegistryKeyNames& rSubKeyNames);
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	/**	closes all keys specified in the array.
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 		@param	rSubKeys reference a RegistryKeyArray which contains the open keys.
469cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
470cdf0e10cSrcweir 	*/
471cdf0e10cSrcweir 	inline RegError closeSubKeys(RegistryKeyArray& rSubKeys);
472cdf0e10cSrcweir 
473cdf0e10cSrcweir 	/**	deletes the specified key.
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which will be deleted.
476cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
477cdf0e10cSrcweir 	*/
478cdf0e10cSrcweir 	inline RegError deleteKey(const ::rtl::OUString& keyName);
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 	/// closes explicitly the current key
481cdf0e10cSrcweir 	inline RegError closeKey();
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 	/// releases the current key
484cdf0e10cSrcweir 	inline void releaseKey();
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 	/**	sets a value of a key.
487cdf0e10cSrcweir 
488cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which value will be set.
489cdf0e10cSrcweir                         If keyName is an empty string, the value will be set for the key
490cdf0e10cSrcweir                         specified by hKey.
491cdf0e10cSrcweir 		@param	valueType specifies the type of the value.
492cdf0e10cSrcweir 		@param	pData points to a memory block containing the data for the value.
493cdf0e10cSrcweir 		@param	valueSize specifies the size of pData in bytes
494cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
495cdf0e10cSrcweir 	*/
496cdf0e10cSrcweir 	inline RegError setValue(const ::rtl::OUString& keyName,
497cdf0e10cSrcweir 				   			 RegValueType valueType,
498cdf0e10cSrcweir 				   			 RegValue pValue,
499cdf0e10cSrcweir 				   			 sal_uInt32 valueSize);
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 	/**	sets a long list value of a key.
502cdf0e10cSrcweir 
503cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which value will be set.
504cdf0e10cSrcweir                         If keyName is an empty string, the value will be set for the key
505cdf0e10cSrcweir                         specified by hKey.
506cdf0e10cSrcweir 		@param	pValueList points to an array of longs containing the data for the value.
507cdf0e10cSrcweir 		@param	len specifies the length of the list (the array referenced by pValueList).
508cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
509cdf0e10cSrcweir 	*/
510cdf0e10cSrcweir 	inline RegError setLongListValue(const ::rtl::OUString& keyName,
511cdf0e10cSrcweir 				   			 		 sal_Int32* pValueList,
512cdf0e10cSrcweir 				   			 		 sal_uInt32 len);
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 	/**	sets an ascii list value of a key.
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which value will be set.
517cdf0e10cSrcweir                         If keyName is an empty string, the value will be set for the key
518cdf0e10cSrcweir                         specified by hKey.
519cdf0e10cSrcweir 		@param	pValueList points to an array of sal_Char* containing the data for the value.
520cdf0e10cSrcweir 		@param	len specifies the length of the list (the array referenced by pValueList).
521cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
522cdf0e10cSrcweir 	*/
523cdf0e10cSrcweir 	inline RegError setStringListValue(const ::rtl::OUString& keyName,
524cdf0e10cSrcweir 				   			 		   sal_Char** pValueList,
525cdf0e10cSrcweir 				   			 		   sal_uInt32 len);
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 	/**	sets an unicode string list value of a key.
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which value will be set.
530cdf0e10cSrcweir                         If keyName is an empty string, the value will be set for the key
531cdf0e10cSrcweir                         specified by hKey.
532cdf0e10cSrcweir 		@param	pValueList points to an array of sal_Unicode* containing the data for the value.
533cdf0e10cSrcweir 		@param	len specifies the length of the list (the array referenced by pValueList).
534cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
535cdf0e10cSrcweir 	*/
536cdf0e10cSrcweir 	inline RegError setUnicodeListValue(const ::rtl::OUString& keyName,
537cdf0e10cSrcweir 				   			 		    sal_Unicode** pValueList,
538cdf0e10cSrcweir 				   			 		  	sal_uInt32 len);
539cdf0e10cSrcweir 
540cdf0e10cSrcweir 	/**	gets info about type and size of a value.
541cdf0e10cSrcweir 
542cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which value info will be returned.
543cdf0e10cSrcweir                         If keyName is an empty string, the value info of the key
544cdf0e10cSrcweir                         specified by hKey will be returned.
545cdf0e10cSrcweir 		@param	pValueType returns the type of the value.
546cdf0e10cSrcweir 		@param	pValueSize returns the size of the value in bytes or the length of a list value.
547cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
548cdf0e10cSrcweir 	*/
549cdf0e10cSrcweir 	inline RegError getValueInfo(const ::rtl::OUString& keyName,
550cdf0e10cSrcweir 					   			 RegValueType* pValueType,
551cdf0e10cSrcweir 					   			 sal_uInt32* pValueSize);
552cdf0e10cSrcweir 
553cdf0e10cSrcweir 	/**	gets the value of a key.
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which value will be returned.
556cdf0e10cSrcweir                         If keyName is an empty string, the value is get from the key
557cdf0e10cSrcweir                         specified by hKey.
558cdf0e10cSrcweir 		@param	pValue points to an allocated memory block receiving the data of the value.
559cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
560cdf0e10cSrcweir 	*/
561cdf0e10cSrcweir 	inline RegError getValue(const ::rtl::OUString& keyName,
562cdf0e10cSrcweir 				   			 RegValue pValue);
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 	/**	gets a long list value of a key.
565cdf0e10cSrcweir 
566cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which value will be returned.
567cdf0e10cSrcweir                         If keyName is an empty string, the value is get from the key
568cdf0e10cSrcweir                         specified by hKey.
569cdf0e10cSrcweir 		@param	rValueList references a RegistryValueList which will be filled with the long values.
570cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
571cdf0e10cSrcweir 	*/
572cdf0e10cSrcweir 	inline RegError getLongListValue(const ::rtl::OUString& keyName,
573cdf0e10cSrcweir 					  	  			  RegistryValueList<sal_Int32>& rValueList);
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 	/**	gets an ascii list value of a key.
576cdf0e10cSrcweir 
577cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which value will be returned.
578cdf0e10cSrcweir                         If keyName is an empty string, the value is get from the key
579cdf0e10cSrcweir                         specified by hKey.
580cdf0e10cSrcweir 		@param	rValueList references a RegistryValueList which will be filled with the ascii values.
581cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
582cdf0e10cSrcweir 	*/
583cdf0e10cSrcweir 	inline RegError getStringListValue(const ::rtl::OUString& keyName,
584cdf0e10cSrcweir 					  	  			   RegistryValueList<sal_Char*>& rValueList);
585cdf0e10cSrcweir 
586cdf0e10cSrcweir 	/**	gets a unicode value of a key.
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 		@param	keyName	specifies the name of the key which value will be returned.
589cdf0e10cSrcweir                         If keyName is an empty string, the value is get from the key
590cdf0e10cSrcweir                         specified by hKey.
591cdf0e10cSrcweir 		@param	rValueList reference a RegistryValueList which will be filled with the unicode values.
592cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
593cdf0e10cSrcweir 	*/
594cdf0e10cSrcweir 	inline RegError getUnicodeListValue(const ::rtl::OUString& keyName,
595cdf0e10cSrcweir 					  	  			  	RegistryValueList<sal_Unicode*>& rValueList);
596cdf0e10cSrcweir 
597cdf0e10cSrcweir     /** used to create a link.
598cdf0e10cSrcweir 
599cdf0e10cSrcweir         @obsolete Links are no longer supported.
600cdf0e10cSrcweir 
601cdf0e10cSrcweir         @return	REG_INVALID_LINK
602cdf0e10cSrcweir      */
603cdf0e10cSrcweir 	inline RegError	createLink(const ::rtl::OUString& linkName,
604cdf0e10cSrcweir 							   const ::rtl::OUString& linkTarget);
605cdf0e10cSrcweir 
606cdf0e10cSrcweir     /** used to delete a link.
607cdf0e10cSrcweir 
608cdf0e10cSrcweir         @obsolete Links are no longer supported.
609cdf0e10cSrcweir 
610cdf0e10cSrcweir         @return	REG_INVALID_LINK
611cdf0e10cSrcweir      */
612cdf0e10cSrcweir 	inline RegError	deleteLink(const ::rtl::OUString& linkName);
613cdf0e10cSrcweir 
614cdf0e10cSrcweir     /** returns the type of the specified key.
615cdf0e10cSrcweir 
616cdf0e10cSrcweir         @param name specifies the name of the key or link.
617cdf0e10cSrcweir         @param pKeyType returns the type of the key (always RG_KEYTYPE).
618cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
619cdf0e10cSrcweir      */
620cdf0e10cSrcweir 	inline RegError	getKeyType(const ::rtl::OUString& name,
621cdf0e10cSrcweir 						   	   RegKeyType* pKeyType) const;
622cdf0e10cSrcweir 
623cdf0e10cSrcweir     /** used to return the target of a link.
624cdf0e10cSrcweir 
625cdf0e10cSrcweir         @obsolete Links are no longer supported.
626cdf0e10cSrcweir 
627cdf0e10cSrcweir         @return	REG_INVALID_LINK
628cdf0e10cSrcweir      */
629cdf0e10cSrcweir 	inline RegError getLinkTarget(const ::rtl::OUString& linkName,
630cdf0e10cSrcweir 							  	  ::rtl::OUString& rLinkTarget) const;
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 	/** resolves a keyname.
633cdf0e10cSrcweir 
634cdf0e10cSrcweir 		@param	keyName specifies the name of the key which will be resolved relativ to this key.
635cdf0e10cSrcweir                         The resolved name will be prefixed with the name of this key.
636cdf0e10cSrcweir         @param firstLinkOnly ignored
637cdf0e10cSrcweir 		@return	REG_NO_ERROR if succeeds else an error code.
638cdf0e10cSrcweir 	 */
639cdf0e10cSrcweir 	inline RegError getResolvedKeyName(const ::rtl::OUString& keyName,
640cdf0e10cSrcweir 									   sal_Bool firstLinkOnly,
641cdf0e10cSrcweir 						  	  		   ::rtl::OUString& rResolvedName) const;
642cdf0e10cSrcweir 
643cdf0e10cSrcweir 	/// returns the name of the registry in which the key is defined.
644cdf0e10cSrcweir 	inline ::rtl::OUString getRegistryName();
645cdf0e10cSrcweir 
646cdf0e10cSrcweir 	/// returns the registry in which the key is defined.
getRegistry() const647cdf0e10cSrcweir 	Registry getRegistry() const { return m_registry; }
648cdf0e10cSrcweir 
649cdf0e10cSrcweir 	friend class Registry;
650cdf0e10cSrcweir public:
651cdf0e10cSrcweir     /** Constructor, which initialize a RegistryKey with registry and an valid key handle.
652cdf0e10cSrcweir 
653cdf0e10cSrcweir         This constructor is internal only.
654cdf0e10cSrcweir         @internal
655cdf0e10cSrcweir     */
656cdf0e10cSrcweir 	inline RegistryKey(Registry&	registry,
657cdf0e10cSrcweir 					   RegKeyHandle hKey);
658cdf0e10cSrcweir 
659cdf0e10cSrcweir     /** returns the internal key handle.
660cdf0e10cSrcweir 
661cdf0e10cSrcweir         @internal
662cdf0e10cSrcweir      */
getKeyHandle() const663cdf0e10cSrcweir 	RegKeyHandle getKeyHandle() const { return m_hImpl; }
664cdf0e10cSrcweir 
665cdf0e10cSrcweir protected:
666cdf0e10cSrcweir     /** sets the internal registry on which this key should work.
667cdf0e10cSrcweir 
668cdf0e10cSrcweir         @internal
669cdf0e10cSrcweir      */
670cdf0e10cSrcweir 	inline void setRegistry(Registry& registry);
671cdf0e10cSrcweir 
672cdf0e10cSrcweir     /// stores the registry on which this key works
673cdf0e10cSrcweir 	Registry		m_registry;
674cdf0e10cSrcweir     /// stores the current key handle of this key
675cdf0e10cSrcweir 	RegKeyHandle	m_hImpl;
676cdf0e10cSrcweir };
677cdf0e10cSrcweir 
678cdf0e10cSrcweir 
679cdf0e10cSrcweir //-----------------------------------------------------------------------------
680cdf0e10cSrcweir 
RegistryKeyArray()681cdf0e10cSrcweir inline RegistryKeyArray::RegistryKeyArray()
682cdf0e10cSrcweir 	: m_length(0)
683cdf0e10cSrcweir 	, m_phKeys(NULL)
684cdf0e10cSrcweir {
685cdf0e10cSrcweir }
686cdf0e10cSrcweir 
~RegistryKeyArray()687cdf0e10cSrcweir inline RegistryKeyArray::~RegistryKeyArray()
688cdf0e10cSrcweir {
689cdf0e10cSrcweir 	if (m_phKeys)
690cdf0e10cSrcweir 		m_registry.m_pApi->closeSubKeys(m_phKeys, m_length);
691cdf0e10cSrcweir }
692cdf0e10cSrcweir 
getElement(sal_uInt32 index)693cdf0e10cSrcweir inline RegistryKey RegistryKeyArray::getElement(sal_uInt32 index)
694cdf0e10cSrcweir {
695cdf0e10cSrcweir 	if (m_registry.isValid() && index < m_length)
696cdf0e10cSrcweir 		return RegistryKey(m_registry, m_phKeys[index]);
697cdf0e10cSrcweir 	else
698cdf0e10cSrcweir 		return RegistryKey();
699cdf0e10cSrcweir }
700cdf0e10cSrcweir 
getLength()701cdf0e10cSrcweir inline sal_uInt32 RegistryKeyArray::getLength()
702cdf0e10cSrcweir {
703cdf0e10cSrcweir 	return m_length;
704cdf0e10cSrcweir }
705cdf0e10cSrcweir 
setKeyHandles(Registry & registry,RegKeyHandle * phKeys,sal_uInt32 length)706cdf0e10cSrcweir inline void RegistryKeyArray::setKeyHandles(Registry& registry,
707cdf0e10cSrcweir 											RegKeyHandle* phKeys,
708cdf0e10cSrcweir 											sal_uInt32 length)
709cdf0e10cSrcweir {
710cdf0e10cSrcweir 	m_phKeys = phKeys;
711cdf0e10cSrcweir 	m_length = length;
712cdf0e10cSrcweir 	m_registry = registry;
713cdf0e10cSrcweir }
714cdf0e10cSrcweir 
closeKeyHandles()715cdf0e10cSrcweir inline RegError RegistryKeyArray::closeKeyHandles()
716cdf0e10cSrcweir {
717cdf0e10cSrcweir 	if (m_registry.isValid() && m_phKeys)
718cdf0e10cSrcweir 	{
719cdf0e10cSrcweir 		RegError ret;
720cdf0e10cSrcweir 		ret = m_registry.m_pApi->closeSubKeys(m_phKeys, m_length);
721cdf0e10cSrcweir 		m_registry = Registry();
722cdf0e10cSrcweir 		m_length = 0;
723cdf0e10cSrcweir 		m_phKeys = NULL;
724cdf0e10cSrcweir 		return ret;
725cdf0e10cSrcweir 	} else
726cdf0e10cSrcweir 		return(REG_INVALID_KEY);
727cdf0e10cSrcweir }
728cdf0e10cSrcweir 
729cdf0e10cSrcweir //-----------------------------------------------------------------------------
730cdf0e10cSrcweir 
RegistryKeyNames()731cdf0e10cSrcweir inline RegistryKeyNames::RegistryKeyNames()
732cdf0e10cSrcweir 	: m_length(0)
733cdf0e10cSrcweir 	, m_pKeyNames(NULL)
734cdf0e10cSrcweir {
735cdf0e10cSrcweir }
736cdf0e10cSrcweir 
~RegistryKeyNames()737cdf0e10cSrcweir inline RegistryKeyNames::~RegistryKeyNames()
738cdf0e10cSrcweir {
739cdf0e10cSrcweir 	if (m_pKeyNames)
740cdf0e10cSrcweir 		m_registry.m_pApi->freeKeyNames(m_pKeyNames, m_length);
741cdf0e10cSrcweir }
742cdf0e10cSrcweir 
getElement(sal_uInt32 index)743cdf0e10cSrcweir inline ::rtl::OUString RegistryKeyNames::getElement(sal_uInt32 index)
744cdf0e10cSrcweir {
745cdf0e10cSrcweir 
746cdf0e10cSrcweir 	if (m_pKeyNames && index < m_length)
747cdf0e10cSrcweir 		return m_pKeyNames[index];
748cdf0e10cSrcweir 	else
749cdf0e10cSrcweir 		return ::rtl::OUString();
750cdf0e10cSrcweir }
751cdf0e10cSrcweir 
getLength()752cdf0e10cSrcweir inline sal_uInt32 RegistryKeyNames::getLength()
753cdf0e10cSrcweir {
754cdf0e10cSrcweir 	return m_length;
755cdf0e10cSrcweir }
756cdf0e10cSrcweir 
setKeyNames(Registry & registry,rtl_uString ** pKeyNames,sal_uInt32 length)757cdf0e10cSrcweir inline void RegistryKeyNames::setKeyNames(Registry& registry,
758cdf0e10cSrcweir 										  rtl_uString** pKeyNames,
759cdf0e10cSrcweir 										  sal_uInt32 length)
760cdf0e10cSrcweir {
761cdf0e10cSrcweir 	m_pKeyNames = pKeyNames;
762cdf0e10cSrcweir 	m_length = length;
763cdf0e10cSrcweir 	m_registry = registry;
764cdf0e10cSrcweir }
765cdf0e10cSrcweir 
freeKeyNames()766cdf0e10cSrcweir inline RegError RegistryKeyNames::freeKeyNames()
767cdf0e10cSrcweir {
768cdf0e10cSrcweir 	if (m_registry.isValid() && m_pKeyNames)
769cdf0e10cSrcweir 	{
770cdf0e10cSrcweir 		RegError ret = REG_NO_ERROR;
771cdf0e10cSrcweir 		ret = m_registry.m_pApi->freeKeyNames(m_pKeyNames, m_length);
772cdf0e10cSrcweir 		m_registry = Registry();
773cdf0e10cSrcweir 		m_length = 0;
774cdf0e10cSrcweir 		m_pKeyNames = NULL;
775cdf0e10cSrcweir 		return ret;
776cdf0e10cSrcweir 	} else
777cdf0e10cSrcweir 		return REG_INVALID_KEY;
778cdf0e10cSrcweir }
779cdf0e10cSrcweir 
780cdf0e10cSrcweir //-----------------------------------------------------------------------------
781cdf0e10cSrcweir 
RegistryKey()782cdf0e10cSrcweir inline RegistryKey::RegistryKey()
783cdf0e10cSrcweir 	: m_hImpl(NULL)
784cdf0e10cSrcweir 	{ }
785cdf0e10cSrcweir 
RegistryKey(Registry & registry,RegKeyHandle hKey)786cdf0e10cSrcweir inline RegistryKey::RegistryKey(Registry& registry, RegKeyHandle hKey)
787cdf0e10cSrcweir 	: m_registry(registry)
788cdf0e10cSrcweir 	, m_hImpl(hKey)
789cdf0e10cSrcweir 	{
790cdf0e10cSrcweir 		if (m_hImpl)
791cdf0e10cSrcweir 			m_registry.m_pApi->acquireKey(m_hImpl);
792cdf0e10cSrcweir 	}
793cdf0e10cSrcweir 
RegistryKey(const RegistryKey & toCopy)794cdf0e10cSrcweir inline RegistryKey::RegistryKey(const RegistryKey& toCopy)
795cdf0e10cSrcweir 	: m_registry(toCopy.m_registry)
796cdf0e10cSrcweir 	, m_hImpl(toCopy.m_hImpl)
797cdf0e10cSrcweir 	{
798cdf0e10cSrcweir 		if (m_hImpl)
799cdf0e10cSrcweir 			m_registry.m_pApi->acquireKey(m_hImpl);
800cdf0e10cSrcweir 	}
801cdf0e10cSrcweir 
setRegistry(Registry & registry)802cdf0e10cSrcweir inline void RegistryKey::setRegistry(Registry& registry)
803cdf0e10cSrcweir 	{
804cdf0e10cSrcweir 		m_registry = registry;
805cdf0e10cSrcweir 	}
806cdf0e10cSrcweir 
~RegistryKey()807cdf0e10cSrcweir inline RegistryKey::~RegistryKey()
808cdf0e10cSrcweir 	{
809cdf0e10cSrcweir 		if (m_hImpl)
810cdf0e10cSrcweir 			m_registry.m_pApi->releaseKey(m_hImpl);
811cdf0e10cSrcweir 	}
812cdf0e10cSrcweir 
operator =(const RegistryKey & toAssign)813cdf0e10cSrcweir inline RegistryKey& RegistryKey::operator = (const RegistryKey& toAssign)
814cdf0e10cSrcweir {
815cdf0e10cSrcweir 	m_registry = toAssign.m_registry;
816cdf0e10cSrcweir 
817cdf0e10cSrcweir 	if (toAssign.m_hImpl)
818cdf0e10cSrcweir 		m_registry.m_pApi->acquireKey(toAssign.m_hImpl);
819cdf0e10cSrcweir 	if (m_hImpl)
820cdf0e10cSrcweir 		m_registry.m_pApi->releaseKey(m_hImpl);
821cdf0e10cSrcweir 	m_hImpl = toAssign.m_hImpl;
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 	return *this;
824cdf0e10cSrcweir }
825cdf0e10cSrcweir 
isValid() const826cdf0e10cSrcweir inline sal_Bool RegistryKey::isValid() const
827cdf0e10cSrcweir 	{  return (m_hImpl != NULL); }
828cdf0e10cSrcweir 
isReadOnly() const829cdf0e10cSrcweir inline sal_Bool RegistryKey::isReadOnly() const
830cdf0e10cSrcweir 	{
831cdf0e10cSrcweir 		if 	(m_registry.isValid())
832cdf0e10cSrcweir 			return (m_registry.m_pApi)->isKeyReadOnly(m_hImpl);
833cdf0e10cSrcweir 		else
834cdf0e10cSrcweir 			return sal_False;
835cdf0e10cSrcweir 	}
836cdf0e10cSrcweir 
getName()837cdf0e10cSrcweir inline ::rtl::OUString RegistryKey::getName()
838cdf0e10cSrcweir 	{
839cdf0e10cSrcweir 		::rtl::OUString sRet;
840cdf0e10cSrcweir 		if (m_registry.isValid())
841cdf0e10cSrcweir 			m_registry.m_pApi->getKeyName(m_hImpl, &sRet.pData);
842cdf0e10cSrcweir 		return sRet;;
843cdf0e10cSrcweir 	}
844cdf0e10cSrcweir 
createKey(const::rtl::OUString & keyName,RegistryKey & rNewKey)845cdf0e10cSrcweir inline RegError RegistryKey::createKey(const ::rtl::OUString& keyName,
846cdf0e10cSrcweir 						   			   RegistryKey& rNewKey)
847cdf0e10cSrcweir 	{
848cdf0e10cSrcweir 		if (rNewKey.isValid()) rNewKey.closeKey();
849cdf0e10cSrcweir 		if (m_registry.isValid())
850cdf0e10cSrcweir 		{
851cdf0e10cSrcweir 			RegError ret = m_registry.m_pApi->createKey(m_hImpl, keyName.pData, &rNewKey.m_hImpl);
852cdf0e10cSrcweir 			if (!ret) rNewKey.setRegistry(m_registry);
853cdf0e10cSrcweir 			return ret;
854cdf0e10cSrcweir 		} else
855cdf0e10cSrcweir 			return REG_INVALID_KEY;
856cdf0e10cSrcweir 	}
857cdf0e10cSrcweir 
openKey(const::rtl::OUString & keyName,RegistryKey & rOpenKey)858cdf0e10cSrcweir inline RegError RegistryKey::openKey(const ::rtl::OUString& keyName,
859cdf0e10cSrcweir 			  			 		  RegistryKey& rOpenKey)
860cdf0e10cSrcweir 	{
861cdf0e10cSrcweir 		if (rOpenKey.isValid()) rOpenKey.closeKey();
862cdf0e10cSrcweir 		if (m_registry.isValid())
863cdf0e10cSrcweir 		{
864cdf0e10cSrcweir 			RegError ret = m_registry.m_pApi->openKey(m_hImpl, keyName.pData,
865cdf0e10cSrcweir 													&rOpenKey.m_hImpl);
866cdf0e10cSrcweir 			if (!ret) rOpenKey.setRegistry(m_registry);
867cdf0e10cSrcweir 			return ret;
868cdf0e10cSrcweir 		} else
869cdf0e10cSrcweir 			return REG_INVALID_KEY;
870cdf0e10cSrcweir 	}
871cdf0e10cSrcweir 
openSubKeys(const::rtl::OUString & keyName,RegistryKeyArray & rSubKeys)872cdf0e10cSrcweir inline RegError RegistryKey::openSubKeys(const ::rtl::OUString& keyName,
873cdf0e10cSrcweir 										 RegistryKeyArray& rSubKeys)
874cdf0e10cSrcweir 	{
875cdf0e10cSrcweir 		if (m_registry.isValid())
876cdf0e10cSrcweir 		{
877cdf0e10cSrcweir 			RegError 		ret = REG_NO_ERROR;
878cdf0e10cSrcweir 			RegKeyHandle* 	pSubKeys;
879cdf0e10cSrcweir 			sal_uInt32 		nSubKeys;
880cdf0e10cSrcweir 	 		ret = m_registry.m_pApi->openSubKeys(m_hImpl, keyName.pData,
881cdf0e10cSrcweir 	 												 &pSubKeys, &nSubKeys);
882cdf0e10cSrcweir 	 		if ( ret )
883cdf0e10cSrcweir 			{
884cdf0e10cSrcweir 				return ret;
885cdf0e10cSrcweir 			} else
886cdf0e10cSrcweir 			{
887cdf0e10cSrcweir 				rSubKeys.setKeyHandles(m_registry, pSubKeys, nSubKeys);
888cdf0e10cSrcweir 				return ret;
889cdf0e10cSrcweir 			}
890cdf0e10cSrcweir 		} else
891cdf0e10cSrcweir 			return REG_INVALID_KEY;
892cdf0e10cSrcweir 	}
893cdf0e10cSrcweir 
getKeyNames(const::rtl::OUString & keyName,RegistryKeyNames & rSubKeyNames)894cdf0e10cSrcweir inline RegError RegistryKey::getKeyNames(const ::rtl::OUString& keyName,
895cdf0e10cSrcweir 					  	  				 RegistryKeyNames& rSubKeyNames)
896cdf0e10cSrcweir 	{
897cdf0e10cSrcweir 		if (m_registry.isValid())
898cdf0e10cSrcweir 		{
899cdf0e10cSrcweir 			RegError 		ret = REG_NO_ERROR;
900cdf0e10cSrcweir 			rtl_uString**	pSubKeyNames;
901cdf0e10cSrcweir 			sal_uInt32 		nSubKeys;
902cdf0e10cSrcweir 	 		ret = m_registry.m_pApi->getKeyNames(m_hImpl, keyName.pData,
903cdf0e10cSrcweir 	 											 &pSubKeyNames, &nSubKeys);
904cdf0e10cSrcweir 	 		if ( ret )
905cdf0e10cSrcweir 			{
906cdf0e10cSrcweir 				return ret;
907cdf0e10cSrcweir 			} else
908cdf0e10cSrcweir 			{
909cdf0e10cSrcweir 				rSubKeyNames.setKeyNames(m_registry, pSubKeyNames, nSubKeys);
910cdf0e10cSrcweir 				return ret;
911cdf0e10cSrcweir 			}
912cdf0e10cSrcweir 		} else
913cdf0e10cSrcweir 			return REG_INVALID_KEY;
914cdf0e10cSrcweir 	}
915cdf0e10cSrcweir 
closeSubKeys(RegistryKeyArray & rSubKeys)916cdf0e10cSrcweir inline RegError RegistryKey::closeSubKeys(RegistryKeyArray& rSubKeys)
917cdf0e10cSrcweir 	{
918cdf0e10cSrcweir 		if (m_registry.isValid())
919cdf0e10cSrcweir 			return rSubKeys.closeKeyHandles();
920cdf0e10cSrcweir 		else
921cdf0e10cSrcweir 			return REG_INVALID_KEY;
922cdf0e10cSrcweir 	}
923cdf0e10cSrcweir 
deleteKey(const::rtl::OUString & keyName)924cdf0e10cSrcweir inline RegError RegistryKey::deleteKey(const ::rtl::OUString& keyName)
925cdf0e10cSrcweir 	{
926cdf0e10cSrcweir 		if (m_registry.isValid())
927cdf0e10cSrcweir 			return m_registry.m_pApi->deleteKey(m_hImpl, keyName.pData);
928cdf0e10cSrcweir 		else
929cdf0e10cSrcweir 			return REG_INVALID_KEY;
930cdf0e10cSrcweir 	}
931cdf0e10cSrcweir 
closeKey()932cdf0e10cSrcweir inline RegError RegistryKey::closeKey()
933cdf0e10cSrcweir 	{
934cdf0e10cSrcweir 		if (m_registry.isValid())
935cdf0e10cSrcweir 		{
936cdf0e10cSrcweir 			RegError ret = m_registry.m_pApi->closeKey(m_hImpl);
937cdf0e10cSrcweir 			if (!ret)
938cdf0e10cSrcweir 			{
939cdf0e10cSrcweir 				m_hImpl = NULL;
940cdf0e10cSrcweir 				m_registry = Registry();
941cdf0e10cSrcweir 			}
942cdf0e10cSrcweir 			return ret;
943cdf0e10cSrcweir 		} else
944cdf0e10cSrcweir 			return REG_INVALID_KEY;
945cdf0e10cSrcweir 	}
946cdf0e10cSrcweir 
releaseKey()947cdf0e10cSrcweir inline void RegistryKey::releaseKey()
948cdf0e10cSrcweir {
949cdf0e10cSrcweir 	if (m_registry.isValid() && (m_hImpl != 0))
950cdf0e10cSrcweir 	{
951cdf0e10cSrcweir 		m_registry.m_pApi->releaseKey(m_hImpl), m_hImpl = 0;
952cdf0e10cSrcweir 	}
953cdf0e10cSrcweir }
954cdf0e10cSrcweir 
setValue(const::rtl::OUString & keyName,RegValueType valueType,RegValue pValue,sal_uInt32 valueSize)955cdf0e10cSrcweir inline RegError RegistryKey::setValue(const ::rtl::OUString& keyName,
956cdf0e10cSrcweir 			   			  		   	  RegValueType valueType,
957cdf0e10cSrcweir 			   			  		      RegValue pValue,
958cdf0e10cSrcweir 			   			  		   	  sal_uInt32 valueSize)
959cdf0e10cSrcweir 	{
960cdf0e10cSrcweir 		if (m_registry.isValid())
961cdf0e10cSrcweir 			return m_registry.m_pApi->setValue(m_hImpl, keyName.pData, valueType,
962cdf0e10cSrcweir 								 			   pValue, valueSize);
963cdf0e10cSrcweir 		else
964cdf0e10cSrcweir 			return REG_INVALID_KEY;
965cdf0e10cSrcweir 	}
966cdf0e10cSrcweir 
setLongListValue(const::rtl::OUString & keyName,sal_Int32 * pValueList,sal_uInt32 len)967cdf0e10cSrcweir inline RegError RegistryKey::setLongListValue(const ::rtl::OUString& keyName,
968cdf0e10cSrcweir 			   			 					  sal_Int32* pValueList,
969cdf0e10cSrcweir 						   			 		  sal_uInt32 len)
970cdf0e10cSrcweir 	{
971cdf0e10cSrcweir 		if (m_registry.isValid())
972cdf0e10cSrcweir 			return m_registry.m_pApi->setLongListValue(m_hImpl, keyName.pData,
973cdf0e10cSrcweir 								 			   		   pValueList, len);
974cdf0e10cSrcweir 		else
975cdf0e10cSrcweir 			return REG_INVALID_KEY;
976cdf0e10cSrcweir 	}
977cdf0e10cSrcweir 
setStringListValue(const::rtl::OUString & keyName,sal_Char ** pValueList,sal_uInt32 len)978cdf0e10cSrcweir inline RegError RegistryKey::setStringListValue(const ::rtl::OUString& keyName,
979cdf0e10cSrcweir 			   			 					   sal_Char** pValueList,
980cdf0e10cSrcweir 						   			 		   sal_uInt32 len)
981cdf0e10cSrcweir 	{
982cdf0e10cSrcweir 		if (m_registry.isValid())
983cdf0e10cSrcweir 			return m_registry.m_pApi->setStringListValue(m_hImpl, keyName.pData,
984cdf0e10cSrcweir 								 			   			pValueList, len);
985cdf0e10cSrcweir 		else
986cdf0e10cSrcweir 			return REG_INVALID_KEY;
987cdf0e10cSrcweir 	}
988cdf0e10cSrcweir 
setUnicodeListValue(const::rtl::OUString & keyName,sal_Unicode ** pValueList,sal_uInt32 len)989cdf0e10cSrcweir inline RegError RegistryKey::setUnicodeListValue(const ::rtl::OUString& keyName,
990cdf0e10cSrcweir 			   			 					   	 sal_Unicode** pValueList,
991cdf0e10cSrcweir 						   			 		   	 sal_uInt32 len)
992cdf0e10cSrcweir 	{
993cdf0e10cSrcweir 		if (m_registry.isValid())
994cdf0e10cSrcweir 			return m_registry.m_pApi->setUnicodeListValue(m_hImpl, keyName.pData,
995cdf0e10cSrcweir 								 			   			  pValueList, len);
996cdf0e10cSrcweir 		else
997cdf0e10cSrcweir 			return REG_INVALID_KEY;
998cdf0e10cSrcweir 	}
999cdf0e10cSrcweir 
getValueInfo(const::rtl::OUString & keyName,RegValueType * pValueType,sal_uInt32 * pValueSize)1000cdf0e10cSrcweir inline RegError RegistryKey::getValueInfo(const ::rtl::OUString& keyName,
1001cdf0e10cSrcweir 				   			  		   	  RegValueType* pValueType,
1002cdf0e10cSrcweir 				   			  		   	  sal_uInt32* pValueSize)
1003cdf0e10cSrcweir 	{
1004cdf0e10cSrcweir 		if (m_registry.isValid())
1005cdf0e10cSrcweir 			return m_registry.m_pApi->getValueInfo(m_hImpl, keyName.pData, pValueType, pValueSize);
1006cdf0e10cSrcweir 		else
1007cdf0e10cSrcweir 			return REG_INVALID_KEY;
1008cdf0e10cSrcweir 	}
1009cdf0e10cSrcweir 
getValue(const::rtl::OUString & keyName,RegValue pValue)1010cdf0e10cSrcweir inline RegError RegistryKey::getValue(const ::rtl::OUString& keyName,
1011cdf0e10cSrcweir 			   			  		   RegValue pValue)
1012cdf0e10cSrcweir 	{
1013cdf0e10cSrcweir 		if (m_registry.isValid())
1014cdf0e10cSrcweir 			return m_registry.m_pApi->getValue(m_hImpl, keyName.pData, pValue);
1015cdf0e10cSrcweir 		else
1016cdf0e10cSrcweir 			return REG_INVALID_KEY;
1017cdf0e10cSrcweir 	}
1018cdf0e10cSrcweir 
getLongListValue(const::rtl::OUString & keyName,RegistryValueList<sal_Int32> & rValueList)1019cdf0e10cSrcweir inline RegError RegistryKey::getLongListValue(const ::rtl::OUString& keyName,
1020cdf0e10cSrcweir 				  	  			  		RegistryValueList<sal_Int32>& rValueList)
1021cdf0e10cSrcweir 	{
1022cdf0e10cSrcweir 		if (m_registry.isValid())
1023cdf0e10cSrcweir 		{
1024cdf0e10cSrcweir 			RegError 	ret = REG_NO_ERROR;
1025cdf0e10cSrcweir 			sal_Int32* 	pValueList;
1026cdf0e10cSrcweir 			sal_uInt32 	length;
1027cdf0e10cSrcweir 	 		ret = m_registry.m_pApi->getLongListValue(m_hImpl, keyName.pData,
1028cdf0e10cSrcweir 	 												 &pValueList, &length);
1029cdf0e10cSrcweir 	 		if ( ret )
1030cdf0e10cSrcweir 			{
1031cdf0e10cSrcweir 				return ret;
1032cdf0e10cSrcweir 			} else
1033cdf0e10cSrcweir 			{
1034cdf0e10cSrcweir 				rValueList.setValueList(m_registry, RG_VALUETYPE_LONGLIST,
1035cdf0e10cSrcweir 										pValueList, length);
1036cdf0e10cSrcweir 				return ret;
1037cdf0e10cSrcweir 			}
1038cdf0e10cSrcweir 		} else
1039cdf0e10cSrcweir 			return REG_INVALID_KEY;
1040cdf0e10cSrcweir 	}
1041cdf0e10cSrcweir 
getStringListValue(const::rtl::OUString & keyName,RegistryValueList<sal_Char * > & rValueList)1042cdf0e10cSrcweir inline RegError RegistryKey::getStringListValue(const ::rtl::OUString& keyName,
1043cdf0e10cSrcweir 				  	  			  				RegistryValueList<sal_Char*>& rValueList)
1044cdf0e10cSrcweir 	{
1045cdf0e10cSrcweir 		if (m_registry.isValid())
1046cdf0e10cSrcweir 		{
1047cdf0e10cSrcweir 			RegError 	ret = REG_NO_ERROR;
1048cdf0e10cSrcweir 			sal_Char** 	pValueList;
1049cdf0e10cSrcweir 			sal_uInt32 	length;
1050cdf0e10cSrcweir 	 		ret = m_registry.m_pApi->getStringListValue(m_hImpl, keyName.pData,
1051cdf0e10cSrcweir 	 												 &pValueList, &length);
1052cdf0e10cSrcweir 	 		if ( ret )
1053cdf0e10cSrcweir 			{
1054cdf0e10cSrcweir 				return ret;
1055cdf0e10cSrcweir 			} else
1056cdf0e10cSrcweir 			{
1057cdf0e10cSrcweir 				rValueList.setValueList(m_registry, RG_VALUETYPE_STRINGLIST,
1058cdf0e10cSrcweir 										pValueList, length);
1059cdf0e10cSrcweir 				return ret;
1060cdf0e10cSrcweir 			}
1061cdf0e10cSrcweir 		} else
1062cdf0e10cSrcweir 			return REG_INVALID_KEY;
1063cdf0e10cSrcweir 	}
1064cdf0e10cSrcweir 
getUnicodeListValue(const::rtl::OUString & keyName,RegistryValueList<sal_Unicode * > & rValueList)1065cdf0e10cSrcweir inline RegError RegistryKey::getUnicodeListValue(const ::rtl::OUString& keyName,
1066cdf0e10cSrcweir 				  	  			  		RegistryValueList<sal_Unicode*>& rValueList)
1067cdf0e10cSrcweir 	{
1068cdf0e10cSrcweir 		if (m_registry.isValid())
1069cdf0e10cSrcweir 		{
1070cdf0e10cSrcweir 			RegError 		ret = REG_NO_ERROR;
1071cdf0e10cSrcweir 			sal_Unicode** 	pValueList;
1072cdf0e10cSrcweir 			sal_uInt32 		length;
1073cdf0e10cSrcweir 	 		ret = m_registry.m_pApi->getUnicodeListValue(m_hImpl, keyName.pData,
1074cdf0e10cSrcweir 	 												 &pValueList, &length);
1075cdf0e10cSrcweir 	 		if ( ret )
1076cdf0e10cSrcweir 			{
1077cdf0e10cSrcweir 				return ret;
1078cdf0e10cSrcweir 			} else
1079cdf0e10cSrcweir 			{
1080cdf0e10cSrcweir 				rValueList.setValueList(m_registry, RG_VALUETYPE_UNICODELIST,
1081cdf0e10cSrcweir 										pValueList, length);
1082cdf0e10cSrcweir 				return ret;
1083cdf0e10cSrcweir 			}
1084cdf0e10cSrcweir 		} else
1085cdf0e10cSrcweir 			return REG_INVALID_KEY;
1086cdf0e10cSrcweir 	}
1087cdf0e10cSrcweir 
createLink(const::rtl::OUString & linkName,const::rtl::OUString & linkTarget)1088cdf0e10cSrcweir inline RegError	RegistryKey::createLink(const ::rtl::OUString& linkName,
1089cdf0e10cSrcweir 						   				const ::rtl::OUString& linkTarget)
1090cdf0e10cSrcweir 	{
1091cdf0e10cSrcweir 		if (m_registry.isValid())
1092cdf0e10cSrcweir 			return m_registry.m_pApi->createLink(m_hImpl, linkName.pData, linkTarget.pData);
1093cdf0e10cSrcweir 		else
1094cdf0e10cSrcweir 			return REG_INVALID_KEY;
1095cdf0e10cSrcweir 	}
1096cdf0e10cSrcweir 
deleteLink(const::rtl::OUString & linkName)1097cdf0e10cSrcweir inline RegError	RegistryKey::deleteLink(const ::rtl::OUString& linkName)
1098cdf0e10cSrcweir 	{
1099cdf0e10cSrcweir 		if (m_registry.isValid())
1100cdf0e10cSrcweir 			return m_registry.m_pApi->deleteLink(m_hImpl, linkName.pData);
1101cdf0e10cSrcweir 		else
1102cdf0e10cSrcweir 			return REG_INVALID_KEY;
1103cdf0e10cSrcweir 	}
1104cdf0e10cSrcweir 
getKeyType(const::rtl::OUString & keyName,RegKeyType * pKeyType) const1105cdf0e10cSrcweir inline RegError	RegistryKey::getKeyType(const ::rtl::OUString& keyName,
1106cdf0e10cSrcweir 					   	   				RegKeyType* pKeyType) const
1107cdf0e10cSrcweir 	{
1108cdf0e10cSrcweir 		if (m_registry.isValid())
1109cdf0e10cSrcweir 			return m_registry.m_pApi->getKeyType(m_hImpl, keyName.pData, pKeyType);
1110cdf0e10cSrcweir 		else
1111cdf0e10cSrcweir 			return REG_INVALID_KEY;
1112cdf0e10cSrcweir 	}
1113cdf0e10cSrcweir 
getLinkTarget(const::rtl::OUString & linkName,::rtl::OUString & rLinkTarget) const1114cdf0e10cSrcweir inline RegError RegistryKey::getLinkTarget(const ::rtl::OUString& linkName,
1115cdf0e10cSrcweir 						  	  			   ::rtl::OUString& rLinkTarget) const
1116cdf0e10cSrcweir 	{
1117cdf0e10cSrcweir 		if (m_registry.isValid())
1118cdf0e10cSrcweir 		{
1119cdf0e10cSrcweir 			return m_registry.m_pApi->getLinkTarget(m_hImpl,
1120cdf0e10cSrcweir 													linkName.pData,
1121cdf0e10cSrcweir 													&rLinkTarget.pData);
1122cdf0e10cSrcweir 		} else
1123cdf0e10cSrcweir 			return REG_INVALID_KEY;
1124cdf0e10cSrcweir 	}
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir 
getResolvedKeyName(const::rtl::OUString & keyName,sal_Bool firstLinkOnly,::rtl::OUString & rResolvedName) const1127cdf0e10cSrcweir inline RegError RegistryKey::getResolvedKeyName(const ::rtl::OUString& keyName,
1128cdf0e10cSrcweir 								   				sal_Bool firstLinkOnly,
1129cdf0e10cSrcweir 					  	  		   				::rtl::OUString& rResolvedName) const
1130cdf0e10cSrcweir 	{
1131cdf0e10cSrcweir 		if (m_registry.isValid())
1132cdf0e10cSrcweir 			return m_registry.m_pApi->getResolvedKeyName(m_hImpl,
1133cdf0e10cSrcweir 														 keyName.pData,
1134cdf0e10cSrcweir 														 firstLinkOnly,
1135cdf0e10cSrcweir 														 &rResolvedName.pData);
1136cdf0e10cSrcweir 		else
1137cdf0e10cSrcweir 			return REG_INVALID_KEY;
1138cdf0e10cSrcweir 	}
1139cdf0e10cSrcweir 
getRegistryName()1140cdf0e10cSrcweir inline ::rtl::OUString RegistryKey::getRegistryName()
1141cdf0e10cSrcweir 	{
1142cdf0e10cSrcweir 		if (m_registry.isValid())
1143cdf0e10cSrcweir 		{
1144cdf0e10cSrcweir 			return m_registry.getName();
1145cdf0e10cSrcweir 		} else
1146cdf0e10cSrcweir 			return ::rtl::OUString();
1147cdf0e10cSrcweir 	}
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir //-----------------------------------------------------------------------------
1150cdf0e10cSrcweir 
Registry()1151cdf0e10cSrcweir inline Registry::Registry()
1152cdf0e10cSrcweir 	: m_pApi(initRegistry_Api())
1153cdf0e10cSrcweir 	, m_hImpl(NULL)
1154cdf0e10cSrcweir 	{ }
1155cdf0e10cSrcweir 
Registry(const Registry & toCopy)1156cdf0e10cSrcweir inline Registry::Registry(const Registry& toCopy)
1157cdf0e10cSrcweir 	: m_pApi(toCopy.m_pApi)
1158cdf0e10cSrcweir 	, m_hImpl(toCopy.m_hImpl)
1159cdf0e10cSrcweir 	{
1160cdf0e10cSrcweir 		if (m_hImpl)
1161cdf0e10cSrcweir 			m_pApi->acquire(m_hImpl);
1162cdf0e10cSrcweir 	}
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir 
~Registry()1165cdf0e10cSrcweir inline Registry::~Registry()
1166cdf0e10cSrcweir 	{
1167cdf0e10cSrcweir 		if (m_hImpl)
1168cdf0e10cSrcweir 			m_pApi->release(m_hImpl);
1169cdf0e10cSrcweir 	}
1170cdf0e10cSrcweir 
operator =(const Registry & toAssign)1171cdf0e10cSrcweir inline Registry& Registry::operator = (const Registry& toAssign)
1172cdf0e10cSrcweir {
1173cdf0e10cSrcweir 	if (toAssign.m_hImpl)
1174cdf0e10cSrcweir 		toAssign.m_pApi->acquire(toAssign.m_hImpl);
1175cdf0e10cSrcweir 	if (m_hImpl)
1176cdf0e10cSrcweir 		m_pApi->release(m_hImpl);
1177cdf0e10cSrcweir 
1178cdf0e10cSrcweir 	m_pApi  = toAssign.m_pApi;
1179cdf0e10cSrcweir 	m_hImpl = toAssign.m_hImpl;
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir 	return *this;
1182cdf0e10cSrcweir }
1183cdf0e10cSrcweir 
isValid() const1184cdf0e10cSrcweir inline sal_Bool Registry::isValid() const
1185cdf0e10cSrcweir 	{  return ( m_hImpl != NULL ); }
1186cdf0e10cSrcweir 
isReadOnly() const1187cdf0e10cSrcweir inline sal_Bool Registry::isReadOnly() const
1188cdf0e10cSrcweir 	{  return m_pApi->isReadOnly(m_hImpl); }
1189cdf0e10cSrcweir 
openRootKey(RegistryKey & rRootKey)1190cdf0e10cSrcweir inline RegError Registry::openRootKey(RegistryKey& rRootKey)
1191cdf0e10cSrcweir 	{
1192cdf0e10cSrcweir 		rRootKey.setRegistry(*this);
1193cdf0e10cSrcweir 		return m_pApi->openRootKey(m_hImpl, &rRootKey.m_hImpl);
1194cdf0e10cSrcweir 	}
1195cdf0e10cSrcweir 
getName()1196cdf0e10cSrcweir inline ::rtl::OUString Registry::getName()
1197cdf0e10cSrcweir 	{
1198cdf0e10cSrcweir 		::rtl::OUString sRet;
1199cdf0e10cSrcweir 		m_pApi->getName(m_hImpl, &sRet.pData);
1200cdf0e10cSrcweir 		return sRet;
1201cdf0e10cSrcweir 	}
1202cdf0e10cSrcweir 
create(const::rtl::OUString & registryName)1203cdf0e10cSrcweir inline RegError Registry::create(const ::rtl::OUString& registryName)
1204cdf0e10cSrcweir 	{
1205cdf0e10cSrcweir 		if (m_hImpl)
1206cdf0e10cSrcweir 			m_pApi->release(m_hImpl);
1207cdf0e10cSrcweir 		return m_pApi->createRegistry(registryName.pData, &m_hImpl);
1208cdf0e10cSrcweir 	}
1209cdf0e10cSrcweir 
open(const::rtl::OUString & registryName,RegAccessMode accessMode)1210cdf0e10cSrcweir inline RegError Registry::open(const ::rtl::OUString& registryName,
1211cdf0e10cSrcweir 				   			   RegAccessMode accessMode)
1212cdf0e10cSrcweir 	{
1213cdf0e10cSrcweir 		if (m_hImpl)
1214cdf0e10cSrcweir 			m_pApi->release(m_hImpl);
1215cdf0e10cSrcweir 		return m_pApi->openRegistry(registryName.pData, &m_hImpl, accessMode);
1216cdf0e10cSrcweir 	}
1217cdf0e10cSrcweir 
close()1218cdf0e10cSrcweir inline RegError Registry::close()
1219cdf0e10cSrcweir 	{
1220cdf0e10cSrcweir 		RegError ret = m_pApi->closeRegistry(m_hImpl);
1221cdf0e10cSrcweir 		if (!ret)
1222cdf0e10cSrcweir 			m_hImpl = NULL;
1223cdf0e10cSrcweir 		return ret;
1224cdf0e10cSrcweir 	}
1225cdf0e10cSrcweir 
destroy(const::rtl::OUString & registryName)1226cdf0e10cSrcweir inline RegError Registry::destroy(const ::rtl::OUString& registryName)
1227cdf0e10cSrcweir 	{
1228cdf0e10cSrcweir 		RegError ret = m_pApi->destroyRegistry(m_hImpl, registryName.pData);
1229cdf0e10cSrcweir 		if ( !ret && (registryName.getLength() == 0) )
1230cdf0e10cSrcweir 			m_hImpl = NULL;
1231cdf0e10cSrcweir 		return ret;
1232cdf0e10cSrcweir 	}
1233cdf0e10cSrcweir 
loadKey(RegistryKey & rKey,const::rtl::OUString & keyName,const::rtl::OUString & regFileName)1234cdf0e10cSrcweir inline RegError Registry::loadKey(RegistryKey& rKey,
1235cdf0e10cSrcweir 			  			 		   const ::rtl::OUString& keyName,
1236cdf0e10cSrcweir 			  			 		   const ::rtl::OUString& regFileName)
1237cdf0e10cSrcweir 	{  return m_pApi->loadKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData); }
1238cdf0e10cSrcweir 
saveKey(RegistryKey & rKey,const::rtl::OUString & keyName,const::rtl::OUString & regFileName)1239cdf0e10cSrcweir inline RegError Registry::saveKey(RegistryKey& rKey,
1240cdf0e10cSrcweir 			  			 		  const ::rtl::OUString& keyName,
1241cdf0e10cSrcweir 			  			 		  const ::rtl::OUString& regFileName)
1242cdf0e10cSrcweir 	{  return m_pApi->saveKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData); }
1243cdf0e10cSrcweir 
mergeKey(RegistryKey & rKey,const::rtl::OUString & keyName,const::rtl::OUString & regFileName,sal_Bool bWarnings,sal_Bool bReport)1244cdf0e10cSrcweir inline RegError Registry::mergeKey(RegistryKey& rKey,
1245cdf0e10cSrcweir 			   			  			const ::rtl::OUString& keyName,
1246cdf0e10cSrcweir 			   			  			const ::rtl::OUString& regFileName,
1247cdf0e10cSrcweir 			   			  			sal_Bool bWarnings,
1248cdf0e10cSrcweir 			   			  			sal_Bool bReport)
1249cdf0e10cSrcweir 	{  return m_pApi->mergeKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData, bWarnings, bReport); }
1250cdf0e10cSrcweir 
dumpRegistry(RegistryKey & rKey)1251cdf0e10cSrcweir inline RegError Registry::dumpRegistry(RegistryKey& rKey)
1252cdf0e10cSrcweir 	{  return m_pApi->dumpRegistry(m_hImpl, rKey.m_hImpl); }
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir #endif
1256