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