1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _REGISTRYWNT_HXX_ 29 #define _REGISTRYWNT_HXX_ 30 31 #include "registry.hxx" 32 33 //--------------------------------------- 34 // constants 35 //--------------------------------------- 36 37 class RegistryKeyImplWinNT : public RegistryKeyImpl 38 { 39 public: 40 41 //############################################ 42 // Queries 43 //############################################ 44 45 /** The number of sub values of the key at hand 46 47 @precond IsOpen = true 48 49 @throws 50 */ 51 virtual size_t GetSubValueCount() const; 52 53 /** The number of sub-keys of the key at hand 54 55 @precond IsOpen = true 56 57 @throws 58 */ 59 virtual size_t GetSubKeyCount() const; 60 61 virtual StringListPtr GetSubKeyNames() const; 62 63 virtual StringListPtr GetSubValueNames() const; 64 65 /** Get the specified registry value 66 67 @precond IsOpen = true 68 */ 69 virtual RegistryValue GetValue(const std::wstring& Name) const; 70 71 /** Get the specified registry value, return the given 72 default value if value not found 73 74 @precond IsOpen = true 75 */ 76 virtual RegistryValue GetValue(const std::wstring& Name, const RegistryValue& Default) const; 77 78 //############################################ 79 // Commands 80 //############################################ 81 82 /** Open the registry key, has no effect if 83 the key is already open 84 85 @precond IsOpen = false 86 87 @throws RegistryWriteAccessDenyException 88 RegistryAccessDenyException 89 */ 90 virtual void Open(bool Writeable = true); 91 92 /** Open the specified sub-key of the registry key 93 at hand 94 95 @precond IsOpen = true 96 HasSubKey(Name) = true 97 98 @throws RegistryIOException 99 RegistryKeyNotFoundException 100 RegistryAccessDeniedException 101 */ 102 virtual RegistryKey OpenSubKey(const std::wstring& Name, bool Writeable = true); 103 104 /** Creates a new sub-key below the key at hand 105 106 @precond IsOpen = true 107 IsWriteable = true 108 109 @throws RegistryIOException 110 RegistryWriteAccessDenyException 111 */ 112 virtual RegistryKey CreateSubKey(const std::wstring& Name); 113 114 /** Deletes a sub-key below the key at hand, the 115 key must not have sub-keys 116 117 @precond IsOpen = true 118 IsWriteable = true 119 120 @throws RegistryIOException 121 RegistryWriteAccessDenyException 122 */ 123 virtual void DeleteSubKey(const std::wstring& Name); 124 125 /** Deletes a sub-key below the key at hand with all 126 its sub-keys 127 128 @precond IsOpen = true 129 IsWriteable = true; 130 131 @throws RegistryIOException 132 RegistryWriteAccessDenyException 133 */ 134 virtual void DeleteSubKeyTree(const std::wstring& Name); 135 136 /** Delete the specified value 137 138 @precond IsOpen = true 139 IsWriteable = true 140 HasValue(Name) = true 141 142 @throws RegistryIOException 143 RegistryWriteAccessDeniedException 144 RegistryValueNotFoundException 145 */ 146 virtual void DeleteValue(const std::wstring& Name); 147 148 /** Set the specified registry value 149 150 @precond IsOpen = true 151 IsWriteable = true 152 153 @throws RegistryIOException 154 RegistryWriteAccessDenyException 155 */ 156 virtual void SetValue(const RegistryValue& Value); 157 158 //############################################ 159 // Creation 160 // 161 // only possible through WindowsRegistry class 162 //############################################ 163 164 protected: 165 /** Create instance and open the specified Registry key 166 167 @throws RegistryWriteAccessDenyException 168 RegistryAccessDenyException 169 RegistryKeyNotFoundException 170 */ 171 RegistryKeyImplWinNT(HKEY RootKey, const std::wstring& KeyName); 172 173 /** Create instance and open the specified Registry key 174 175 @throws RegistryWriteAccessDenyException 176 RegistryAccessDenyException 177 RegistryKeyNotFoundException 178 */ 179 RegistryKeyImplWinNT(HKEY RootKey); 180 181 /** Create an instances of the specified Registry key, 182 the key is assumed to be already opened. 183 */ 184 RegistryKeyImplWinNT(HKEY RootKey, HKEY SubKey, const std::wstring& KeyName, bool Writeable = true); 185 186 private: 187 188 LONG ImplDeleteSubKeyTree(HKEY RootKey, const std::wstring& Name); 189 190 //prevent copy and assignment 191 private: 192 RegistryKeyImplWinNT(const RegistryKeyImplWinNT&); 193 RegistryKeyImplWinNT& operator=(const RegistryKeyImplWinNT&); 194 195 //###################################### 196 // Friend declarations 197 //###################################### 198 199 friend class WindowsRegistry; 200 }; 201 202 #endif 203