1 |
|
2 | var Registry = require(__dirname+'/lib/registry.js')
|
3 |
|
4 | // create a registry client
|
5 | , r1 = new Registry({
|
6 | hive: Registry.HKCU,
|
7 | key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Run'
|
8 | })
|
9 | , r2 = new Registry({
|
10 | hive: Registry.HKCU,
|
11 | key: '\\Control Panel\\Desktop'
|
12 | })
|
13 |
|
14 | // get parent key
|
15 | console.log('parent of "'+r2.path+'" -> "'+r2.parent.path+'"');
|
16 |
|
17 | // list subkeys
|
18 | r2
|
19 | . keys(function (err, items) {
|
20 |
|
21 | if (!err)
|
22 | for (var i in items)
|
23 | console.log('subkey of "'+r2.path+'": '+items[i].path);
|
24 |
|
25 | // list values
|
26 | r1
|
27 | . values(function (err, items) {
|
28 |
|
29 | if (!err)
|
30 | console.log(JSON.stringify(items, null, '\t'));
|
31 |
|
32 | // query named value
|
33 | r1
|
34 | . get(items[0].name, function (err, item) {
|
35 |
|
36 | if (!err)
|
37 | console.log(JSON.stringify(item, null, '\t'));
|
38 |
|
39 | // add value
|
40 | r1
|
41 | . set('bla', Registry.REG_SZ, 'hello world!', function (err) {
|
42 |
|
43 | if (!err)
|
44 | console.log('value written');
|
45 |
|
46 | // delete value
|
47 | r1
|
48 | . remove('bla', function (err) {
|
49 |
|
50 | if (!err)
|
51 | console.log('value deleted');
|
52 |
|
53 | })
|
54 | ;
|
55 | })
|
56 | ;
|
57 | })
|
58 | ;
|
59 | })
|
60 | ;
|
61 |
|
62 | })
|
63 | ;
|