forked from DonJayamanne/vscode-python-manager
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwindowsRegistry.ts
More file actions
51 lines (45 loc) · 1.41 KB
/
Copy pathwindowsRegistry.ts
File metadata and controls
51 lines (45 loc) · 1.41 KB
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { HKCU, HKLM, Options, REG_SZ, Registry, RegistryItem } from 'winreg';
import { createDeferred } from '../../common/utils/async';
export { HKCU, HKLM, REG_SZ, Options };
export interface IRegistryKey {
hive: string;
arch: string;
key: string;
parentKey?: IRegistryKey;
}
export interface IRegistryValue {
hive: string;
arch: string;
key: string;
name: string;
type: string;
value: string;
}
export async function readRegistryValues(options: Options): Promise<IRegistryValue[]> {
// eslint-disable-next-line global-require
const WinReg = require('winreg');
const regKey = new WinReg(options);
const deferred = createDeferred<RegistryItem[]>();
regKey.values((err: Error, res: RegistryItem[]) => {
if (err) {
deferred.reject(err);
}
deferred.resolve(res);
});
return deferred.promise;
}
export async function readRegistryKeys(options: Options): Promise<IRegistryKey[]> {
// eslint-disable-next-line global-require
const WinReg = require('winreg');
const regKey = new WinReg(options);
const deferred = createDeferred<Registry[]>();
regKey.keys((err: Error, res: Registry[]) => {
if (err) {
deferred.reject(err);
}
deferred.resolve(res);
});
return deferred.promise;
}