1+ // Type definitions for Winreg v1.2.0
2+ // Project: http://fresc81.github.io/node-winreg/
3+ // Definitions by: RX14 <https://github.com/RX14>, BobBuehler <https://github.com/BobBuehler>
4+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
6+ declare var Winreg : WinregStatic ;
7+
8+ interface WinregStatic {
9+ /**
10+ * Creates a registry object, which provides access to a single registry key.
11+ * Note: This class is returned by a call to ```require('winreg')```.
12+ *
13+ * @public
14+ * @class
15+ *
16+ * @param {@link Options } options - the options
17+ *
18+ * @example
19+ * var Registry = require('winreg')
20+ * , autoStartCurrentUser = new Registry({
21+ * hive: Registry.HKCU,
22+ * key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Run'
23+ * });
24+ */
25+ new ( options : Winreg . Options ) : Winreg . Registry ;
26+
27+ /**
28+ * Registry hive key HKEY_LOCAL_MACHINE.
29+ * Note: For writing to this hive your program has to run with admin privileges.
30+ */
31+ HKLM : string ;
32+
33+ /**
34+ * Registry hive key HKEY_CURRENT_USER.
35+ */
36+ HKCU : string ;
37+
38+ /**
39+ * Registry hive key HKEY_CLASSES_ROOT.
40+ * Note: For writing to this hive your program has to run with admin privileges.
41+ */
42+ HKCR : string ;
43+
44+ /**
45+ * Registry hive key HKEY_USERS.
46+ * Note: For writing to this hive your program has to run with admin privileges.
47+ */
48+ HKU : string ;
49+
50+ /**
51+ * Registry hive key HKEY_CURRENT_CONFIG.
52+ * Note: For writing to this hive your program has to run with admin privileges.
53+ */
54+ HKCC : string ;
55+
56+ /**
57+ * Collection of available registry hive keys.
58+ */
59+ HIVES : Array < string > ;
60+
61+ /**
62+ * Registry value type STRING.
63+ *
64+ * Values of this type contain a string.
65+ */
66+ REG_SZ : string ;
67+
68+ /**
69+ * Registry value type MULTILINE_STRING.
70+ *
71+ * Values of this type contain a multiline string.
72+ */
73+ REG_MULTI_SZ : string ;
74+
75+ /**
76+ * Registry value type EXPANDABLE_STRING.
77+ *
78+ * Values of this type contain an expandable string.
79+ */
80+ REG_EXPAND_SZ : string ;
81+
82+ /**
83+ * Registry value type DOUBLE_WORD.
84+ *
85+ * Values of this type contain a double word (32 bit integer).
86+ */
87+ REG_DWORD : string ;
88+
89+ /**
90+ * Registry value type QUAD_WORD.
91+ *
92+ * Values of this type contain a quad word (64 bit integer).
93+ */
94+ REG_QWORD : string ;
95+
96+ /**
97+ * Registry value type BINARY.
98+ *
99+ * Values of this type contain a binary value.
100+ */
101+ REG_BINARY : string ;
102+
103+ /**
104+ * Registry value type UNKNOWN.
105+ *
106+ * Values of this type contain a value of an unknown type.
107+ */
108+ REG_NONE : string ;
109+
110+ /**
111+ * Collection of available registry value types.
112+ */
113+ REG_TYPES : Array < string > ;
114+
115+ /**
116+ * The name of the default value. May be used instead of the empty string literal for better readability.
117+ */
118+ DEFAULT_VALUE : string ;
119+ }
120+
121+ declare namespace Winreg {
122+ export interface Options {
123+ /**
124+ * Optional hostname, must start with '\\' sequence.
125+ */
126+ host ?: string ;
127+
128+ /**
129+ * Optional hive ID, default is HKLM.
130+ */
131+ hive ?: string ;
132+
133+ /**
134+ * Optional key, default is the root key.
135+ */
136+ key ?: string ;
137+
138+ /**
139+ * Optional registry hive architecture ('x86' or 'x64'; only valid on Windows 64 Bit Operating Systems).
140+ */
141+ arch ?: string ;
142+ }
143+
144+ /**
145+ * A registry object, which provides access to a single registry key.
146+ */
147+ export interface Registry {
148+ /**
149+ * The hostname.
150+ * @readonly
151+ */
152+ host : string ;
153+
154+ /**
155+ * The hive id.
156+ * @readonly
157+ */
158+ hive : string ;
159+
160+ /**
161+ * The registry key name.
162+ * @readonly
163+ */
164+ key : string ;
165+
166+ /**
167+ * The full path to the registry key.
168+ * @readonly
169+ */
170+ path : string ;
171+
172+ /**
173+ * The registry hive architecture ('x86' or 'x64').
174+ * @readonly
175+ */
176+ arch : string ;
177+
178+ /**
179+ * Creates a new {@link Registry} instance that points to the parent registry key.
180+ * @readonly
181+ */
182+ parent : Registry ;
183+
184+ /**
185+ * Retrieve all values from this registry key.
186+ * @param {valuesCallback } cb - callback function
187+ * @param {error= } cb.err - error object or null if successful
188+ * @param {array= } cb.items - an array of {@link RegistryItem} objects
189+ * @returns {Registry } this registry key object
190+ */
191+ values ( cb : ( err : Error , result : Array < Winreg . RegistryItem > ) => void ) : Registry ;
192+
193+ /**
194+ * Retrieve all subkeys from this registry key.
195+ * @param {function (err, items) } cb - callback function
196+ * @param {error= } cb.err - error object or null if successful
197+ * @param {array= } cb.items - an array of {@link Registry} objects
198+ * @returns {Registry } this registry key object
199+ */
200+ keys ( cb : ( err : Error , result : Array < Registry > ) => void ) : Registry ;
201+
202+ /**
203+ * Gets a named value from this registry key.
204+ * @param {string } name - the value name, use {@link Registry.DEFAULT_VALUE} or an empty string for the default value
205+ * @param {function (err, item) } cb - callback function
206+ * @param {error= } cb.err - error object or null if successful
207+ * @param {RegistryItem= } cb.item - the retrieved registry item
208+ * @returns {Registry } this registry key object
209+ */
210+ get ( name : string , cb : ( err : Error , result : Winreg . RegistryItem ) => void ) : Registry ;
211+
212+ /**
213+ * Sets a named value in this registry key, overwriting an already existing value.
214+ * @param {string } name - the value name, use {@link Registry.DEFAULT_VALUE} or an empty string for the default value
215+ * @param {string } type - the value type
216+ * @param {string } value - the value
217+ * @param {function (err) } cb - callback function
218+ * @param {error= } cb.err - error object or null if successful
219+ * @returns {Registry } this registry key object
220+ */
221+ set ( name : string , type : string , value : string , cb : ( err : Error ) => void ) : Registry ;
222+
223+ /**
224+ * Remove a named value from this registry key. If name is empty, sets the default value of this key.
225+ * Note: This key must be already existing.
226+ * @param {string } name - the value name, use {@link Registry.DEFAULT_VALUE} or an empty string for the default value
227+ * @param {function (err) } cb - callback function
228+ * @param {error= } cb.err - error object or null if successful
229+ * @returns {Registry } this registry key object
230+ */
231+ remove ( name : string , cb : ( err : Error ) => void ) : Registry ;
232+
233+ /**
234+ * Remove all subkeys and values (including the default value) from this registry key.
235+ * @param {function (err) } cb - callback function
236+ * @param {error= } cb.err - error object or null if successful
237+ * @returns {Registry } this registry key object
238+ */
239+ clear ( cb : ( err : Error ) => void ) : Registry ;
240+
241+ /**
242+ * Alias for the clear method to keep it backward compatible.
243+ * @method
244+ * @deprecated Use {@link Registry#clear} or {@link Registry#destroy} in favour of this method.
245+ * @param {function (err) } cb - callback function
246+ * @param {error= } cb.err - error object or null if successful
247+ * @returns {Registry } this registry key object
248+ */
249+ erase ( cb : ( err : Error ) => void ) : Registry ;
250+
251+ /**
252+ * Delete this key and all subkeys from the registry.
253+ * @param {function (err) } cb - callback function
254+ * @param {error= } cb.err - error object or null if successful
255+ * @returns {Registry } this registry key object
256+ */
257+ destroy ( cb : ( err : Error ) => void ) : Registry ;
258+
259+ /**
260+ * Create this registry key. Note that this is a no-op if the key already exists.
261+ * @param {function (err) } cb - callback function
262+ * @param {error= } cb.err - error object or null if successful
263+ * @returns {Registry } this registry key object
264+ */
265+ create ( cb : ( err : Error ) => void ) : Registry ;
266+
267+ /**
268+ * Checks if this key already exists.
269+ * @param {function (err, exists) } cb - callback function
270+ * @param {error= } cb.err - error object or null if successful
271+ * @param {boolean= } cb.exists - true if a registry key with this name already exists
272+ * @returns {Registry } this registry key object
273+ */
274+ keyExists ( cb : ( err : Error , exists : boolean ) => void ) : Registry ;
275+
276+ /**
277+ * Checks if a value with the given name already exists within this key.
278+ * @param {string } name - the value name, use {@link Registry.DEFAULT_VALUE} or an empty string for the default value
279+ * @param {function (err, exists) } cb - callback function
280+ * @param {error= } cb.err - error object or null if successful
281+ * @param {boolean= } cb.exists - true if a value with the given name was found in this key
282+ * @returns {Registry } this registry key object
283+ */
284+ valueExists ( name : string , cb : ( err : Error , exists : boolean ) => void ) : Registry ;
285+ }
286+
287+ /**
288+ * A single registry value record.
289+ * Objects of this type are created internally and returned by methods of {@link Registry} objects.
290+ */
291+ export interface RegistryItem {
292+ /**
293+ * The hostname.
294+ * @readonly
295+ */
296+ host : string ;
297+
298+ /**
299+ * The hive id.
300+ * @readonly
301+ */
302+ hive : string ;
303+
304+ /**
305+ * The registry key.
306+ * @readonly
307+ */
308+ key : string ;
309+
310+ /**
311+ * The value name.
312+ * @readonly
313+ */
314+ name : string ;
315+
316+ /**
317+ * The value type.
318+ * @readonly
319+ */
320+ type : string ;
321+
322+ /**
323+ * The value.
324+ * @readonly
325+ */
326+ value : string ;
327+
328+ /**
329+ * The hive architecture.
330+ * @readonly
331+ */
332+ arch : string ;
333+ }
334+ }
335+
336+ declare module "winreg" {
337+ export = Winreg ;
338+ }
0 commit comments