|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #include "nsISupports.idl" |
|
8 |
|
9 native HKEY(HKEY); |
|
10 |
|
11 /** |
|
12 * This interface is designed to provide scriptable access to the Windows |
|
13 * registry system ("With Great Power Comes Great Responsibility"). The |
|
14 * interface represents a single key in the registry. |
|
15 * |
|
16 * This interface is highly Win32 specific. |
|
17 */ |
|
18 [scriptable, uuid(2555b930-d64f-437e-9be7-0a2cb252c1f4)] |
|
19 interface nsIWindowsRegKey : nsISupports |
|
20 { |
|
21 /** |
|
22 * Root keys. The values for these keys correspond to the values from |
|
23 * WinReg.h in the MS Platform SDK. The ROOT_KEY_ prefix corresponds to the |
|
24 * HKEY_ prefix in the MS Platform SDK. |
|
25 * |
|
26 * This interface is not restricted to using only these root keys. |
|
27 */ |
|
28 const unsigned long ROOT_KEY_CLASSES_ROOT = 0x80000000; |
|
29 const unsigned long ROOT_KEY_CURRENT_USER = 0x80000001; |
|
30 const unsigned long ROOT_KEY_LOCAL_MACHINE = 0x80000002; |
|
31 |
|
32 /** |
|
33 * Values for the mode parameter passed to the open and create methods. |
|
34 * The values defined here correspond to the REGSAM values defined in |
|
35 * WinNT.h in the MS Platform SDK, where ACCESS_ is replaced with KEY_. |
|
36 * |
|
37 * This interface is not restricted to using only these access types. |
|
38 */ |
|
39 const unsigned long ACCESS_BASIC = 0x00020000; |
|
40 const unsigned long ACCESS_QUERY_VALUE = 0x00000001; |
|
41 const unsigned long ACCESS_SET_VALUE = 0x00000002; |
|
42 const unsigned long ACCESS_CREATE_SUB_KEY = 0x00000004; |
|
43 const unsigned long ACCESS_ENUMERATE_SUB_KEYS = 0x00000008; |
|
44 const unsigned long ACCESS_NOTIFY = 0x00000010; |
|
45 const unsigned long ACCESS_READ = ACCESS_BASIC | |
|
46 ACCESS_QUERY_VALUE | |
|
47 ACCESS_ENUMERATE_SUB_KEYS | |
|
48 ACCESS_NOTIFY; |
|
49 const unsigned long ACCESS_WRITE = ACCESS_BASIC | |
|
50 ACCESS_SET_VALUE | |
|
51 ACCESS_CREATE_SUB_KEY; |
|
52 const unsigned long ACCESS_ALL = ACCESS_READ | |
|
53 ACCESS_WRITE; |
|
54 const unsigned long WOW64_32 = 0x00000200; |
|
55 const unsigned long WOW64_64 = 0x00000100; |
|
56 |
|
57 |
|
58 /** |
|
59 * Values for the type of a registry value. The numeric values of these |
|
60 * constants are taken directly from WinNT.h in the MS Platform SDK. |
|
61 * The Microsoft documentation should be consulted for the exact meaning of |
|
62 * these value types. |
|
63 * |
|
64 * This interface is somewhat restricted to using only these value types. |
|
65 * There is no method that is directly equivalent to RegQueryValueEx or |
|
66 * RegSetValueEx. In particular, this interface does not support the |
|
67 * REG_MULTI_SZ and REG_EXPAND_SZ value types. It is still possible to |
|
68 * enumerate values that have other types (i.e., getValueType may return a |
|
69 * type not defined below). |
|
70 */ |
|
71 const unsigned long TYPE_NONE = 0; // REG_NONE |
|
72 const unsigned long TYPE_STRING = 1; // REG_SZ |
|
73 const unsigned long TYPE_BINARY = 3; // REG_BINARY |
|
74 const unsigned long TYPE_INT = 4; // REG_DWORD |
|
75 const unsigned long TYPE_INT64 = 11; // REG_QWORD |
|
76 |
|
77 /** |
|
78 * This attribute exposes the native HKEY and is available to provide C++ |
|
79 * consumers with the flexibility of making other Windows registry API calls |
|
80 * that are not exposed via this interface. |
|
81 * |
|
82 * It is possible to initialize this object by setting an HKEY on it. In |
|
83 * that case, it is the responsibility of the consumer setting the HKEY to |
|
84 * ensure that it is a valid HKEY. |
|
85 * |
|
86 * WARNING: Setting the key does not close the old key. |
|
87 */ |
|
88 [noscript] attribute HKEY key; |
|
89 |
|
90 /** |
|
91 * This method closes the key. If the key is already closed, then this |
|
92 * method does nothing. |
|
93 */ |
|
94 void close(); |
|
95 |
|
96 /** |
|
97 * This method opens an existing key. This method fails if the key |
|
98 * does not exist. |
|
99 * |
|
100 * NOTE: On 32-bit Windows, it is valid to pass any HKEY as the rootKey |
|
101 * parameter of this function. However, for compatibility with 64-bit |
|
102 * Windows, that usage should probably be avoided in favor of openChild. |
|
103 * |
|
104 * @param rootKey |
|
105 * A root key defined above or any valid HKEY on 32-bit Windows. |
|
106 * @param relPath |
|
107 * A relative path from the given root key. |
|
108 * @param mode |
|
109 * Access mode, which is a bit-wise OR of the ACCESS_ values defined |
|
110 * above. |
|
111 */ |
|
112 void open(in unsigned long rootKey, in AString relPath, in unsigned long mode); |
|
113 |
|
114 /** |
|
115 * This method opens an existing key or creates a new key. |
|
116 * |
|
117 * NOTE: On 32-bit Windows, it is valid to pass any HKEY as the rootKey |
|
118 * parameter of this function. However, for compatibility with 64-bit |
|
119 * Windows, that usage should probably be avoided in favor of createChild. |
|
120 * |
|
121 * @param rootKey |
|
122 * A root key defined above or any valid HKEY on 32-bit Windows. |
|
123 * @param relPath |
|
124 * A relative path from the given root key. |
|
125 * @param mode |
|
126 * Access mode, which is a bit-wise OR of the ACCESS_ values defined |
|
127 * above. |
|
128 */ |
|
129 void create(in unsigned long rootKey, in AString relPath, in unsigned long mode); |
|
130 |
|
131 /** |
|
132 * This method opens a subkey relative to this key. This method fails if the |
|
133 * key does not exist. |
|
134 * |
|
135 * @return nsIWindowsRegKey for the newly opened subkey. |
|
136 */ |
|
137 nsIWindowsRegKey openChild(in AString relPath, in unsigned long mode); |
|
138 |
|
139 /** |
|
140 * This method opens or creates a subkey relative to this key. |
|
141 * |
|
142 * @return nsIWindowsRegKey for the newly opened or created subkey. |
|
143 */ |
|
144 nsIWindowsRegKey createChild(in AString relPath, in unsigned long mode); |
|
145 |
|
146 /** |
|
147 * This attribute returns the number of child keys. |
|
148 */ |
|
149 readonly attribute unsigned long childCount; |
|
150 |
|
151 /** |
|
152 * This method returns the name of the n'th child key. |
|
153 * |
|
154 * @param index |
|
155 * The index of the requested child key. |
|
156 */ |
|
157 AString getChildName(in unsigned long index); |
|
158 |
|
159 /** |
|
160 * This method checks to see if the key has a child by the given name. |
|
161 * |
|
162 * @param name |
|
163 * The name of the requested child key. |
|
164 */ |
|
165 boolean hasChild(in AString name); |
|
166 |
|
167 /** |
|
168 * This attribute returns the number of values under this key. |
|
169 */ |
|
170 readonly attribute unsigned long valueCount; |
|
171 |
|
172 /** |
|
173 * This method returns the name of the n'th value under this key. |
|
174 * |
|
175 * @param index |
|
176 * The index of the requested value. |
|
177 */ |
|
178 AString getValueName(in unsigned long index); |
|
179 |
|
180 /** |
|
181 * This method checks to see if the key has a value by the given name. |
|
182 * |
|
183 * @param name |
|
184 * The name of the requested value. |
|
185 */ |
|
186 boolean hasValue(in AString name); |
|
187 |
|
188 /** |
|
189 * This method removes a child key and all of its values. This method will |
|
190 * fail if the key has any children of its own. |
|
191 * |
|
192 * @param relPath |
|
193 * The relative path from this key to the key to be removed. |
|
194 */ |
|
195 void removeChild(in AString relPath); |
|
196 |
|
197 /** |
|
198 * This method removes the value with the given name. |
|
199 * |
|
200 * @param name |
|
201 * The name of the value to be removed. |
|
202 */ |
|
203 void removeValue(in AString name); |
|
204 |
|
205 /** |
|
206 * This method returns the type of the value with the given name. The return |
|
207 * value is one of the "TYPE_" constants defined above. |
|
208 * |
|
209 * @param name |
|
210 * The name of the value to query. |
|
211 */ |
|
212 unsigned long getValueType(in AString name); |
|
213 |
|
214 /** |
|
215 * This method reads the string contents of the named value as a Unicode |
|
216 * string. |
|
217 * |
|
218 * @param name |
|
219 * The name of the value to query. This parameter can be the empty |
|
220 * string to request the key's default value. |
|
221 */ |
|
222 AString readStringValue(in AString name); |
|
223 |
|
224 /** |
|
225 * This method reads the integer contents of the named value. |
|
226 * |
|
227 * @param name |
|
228 * The name of the value to query. |
|
229 */ |
|
230 unsigned long readIntValue(in AString name); |
|
231 |
|
232 /** |
|
233 * This method reads the 64-bit integer contents of the named value. |
|
234 * |
|
235 * @param name |
|
236 * The name of the value to query. |
|
237 */ |
|
238 unsigned long long readInt64Value(in AString name); |
|
239 |
|
240 /** |
|
241 * This method reads the binary contents of the named value under this key. |
|
242 * |
|
243 * JavaScript callers should take care with the result of this method since |
|
244 * it will be byte-expanded to form a JS string. (The binary data will be |
|
245 * treated as an ISO-Latin-1 character string, which it is not). |
|
246 * |
|
247 * @param name |
|
248 * The name of the value to query. |
|
249 */ |
|
250 ACString readBinaryValue(in AString name); |
|
251 |
|
252 /** |
|
253 * This method writes the unicode string contents of the named value. The |
|
254 * value will be created if it does not already exist. |
|
255 * |
|
256 * @param name |
|
257 * The name of the value to modify. This parameter can be the empty |
|
258 * string to modify the key's default value. |
|
259 * @param data |
|
260 * The data for the value to modify. |
|
261 */ |
|
262 void writeStringValue(in AString name, in AString data); |
|
263 |
|
264 /** |
|
265 * This method writes the integer contents of the named value. The value |
|
266 * will be created if it does not already exist. |
|
267 * |
|
268 * @param name |
|
269 * The name of the value to modify. |
|
270 * @param data |
|
271 * The data for the value to modify. |
|
272 */ |
|
273 void writeIntValue(in AString name, in unsigned long data); |
|
274 |
|
275 /** |
|
276 * This method writes the 64-bit integer contents of the named value. The |
|
277 * value will be created if it does not already exist. |
|
278 * |
|
279 * @param name |
|
280 * The name of the value to modify. |
|
281 * @param data |
|
282 * The data for the value to modify. |
|
283 */ |
|
284 void writeInt64Value(in AString name, in unsigned long long data); |
|
285 |
|
286 /** |
|
287 * This method writes the binary contents of the named value. The value will |
|
288 * be created if it does not already exist. |
|
289 * |
|
290 * JavaScript callers should take care with the value passed to this method |
|
291 * since it will be truncated from a JS string (unicode) to a ISO-Latin-1 |
|
292 * string. (The binary data will be treated as an ISO-Latin-1 character |
|
293 * string, which it is not). So, JavaScript callers should only pass |
|
294 * character values in the range \u0000 to \u00FF, or else data loss will |
|
295 * occur. |
|
296 * |
|
297 * @param name |
|
298 * The name of the value to modify. |
|
299 * @param data |
|
300 * The data for the value to modify. |
|
301 */ |
|
302 void writeBinaryValue(in AString name, in ACString data); |
|
303 |
|
304 /** |
|
305 * This method starts watching the key to see if any of its values have |
|
306 * changed. The key must have been opened with mode including ACCESS_NOTIFY. |
|
307 * If recurse is true, then this key and any of its descendant keys are |
|
308 * watched. Otherwise, only this key is watched. |
|
309 * |
|
310 * @param recurse |
|
311 * Indicates whether or not to also watch child keys. |
|
312 */ |
|
313 void startWatching(in boolean recurse); |
|
314 |
|
315 /** |
|
316 * This method stops any watching of the key initiated by a call to |
|
317 * startWatching. This method does nothing if the key is not being watched. |
|
318 */ |
|
319 void stopWatching(); |
|
320 |
|
321 /** |
|
322 * This method returns true if the key is being watched for changes (i.e., |
|
323 * if startWatching() was called). |
|
324 */ |
|
325 boolean isWatching(); |
|
326 |
|
327 /** |
|
328 * This method returns true if the key has changed and false otherwise. |
|
329 * This method will always return false if startWatching was not called. |
|
330 */ |
|
331 boolean hasChanged(); |
|
332 }; |