You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To create a file association you can call the `fileAssociation.associateExeForFile` api which will make windows assign a default program for
18
+
To create a file association, you can call the `fileAssociation.associateExeForFile` api which will make windows assign a default program for
19
19
an arbitrary file extension:
20
20
21
21
```js
22
-
var utils =require('windows-registry');
22
+
var utils =require('windows-registry').utils;
23
23
utils.associateExeForFile('myTestHandler', 'A test handler for unit tests', 'C:\\path\\to\\icon', 'C:\\Program Files\\nodejs\\node.exe %1', '.zzz');
24
24
```
25
25
## Reading / Writing to the Windows Registry
@@ -39,6 +39,7 @@ var key = new Key(windef.HKEY.HKEY_CLASSES_ROOT, '.txt', windef.KEY_ACCESS.KEY_A
39
39
Or you can open a sub key from an already opened key:
40
40
41
41
```js
42
+
var Key =require('windows-registry').Key;
42
43
var key =newKey(windef.HKEY.HKEY_CLASSES_ROOT, '', windef.KEY_ACCESS.KEY_ALL_ACCESS);
43
44
var key2 =key.openSubKey('.txt', windef.KEY_ACCESS.KEY_ALL_ACCESS);
44
45
```
@@ -54,8 +55,9 @@ key.close();
54
55
Creating a key just requires that you have a [Key](lib/key.js) object by either using the [predefined keys](https://github.com/CatalystCode/windows-registry-node/blob/master/lib/windef.js#L27) within the `windef.HKEY` or opening a subkey from an existing key.
55
56
56
57
```js
58
+
var Key =require('windows-registry').Key;
57
59
// predefined key
58
-
var key =registry.openKeyFromPredefined(windef.HKEY.HKEY_CLASSES_ROOT, '.txt', windef.KEY_ACCESS.KEY_ALL_ACCESS);
60
+
var key =newKey(windef.HKEY.HKEY_CLASSES_ROOT, '', windef.KEY_ACCESS.KEY_ALL_ACCESS);
59
61
var createdKey =key.createSubKey('\test_key_name', windef.KEY_ACCESS.KEY_ALL_ACCESS);
60
62
```
61
63
@@ -69,9 +71,12 @@ createdKey.deleteKey();
69
71
70
72
### Write a Value to a Key
71
73
72
-
To write a value, you'll again need a [Key](lib/key.js) object and just need to call the `registry.setValueForKeyObject` function:
74
+
To write a value, you'll again need a [Key](lib/key.js) object and just need to call the `Key.setValue` function:
73
75
74
76
```js
77
+
var Key =require('windows-registry').Key,
78
+
windef =require('windows-registry').windef;
79
+
75
80
var key =newKey(windef.HKEY.HKEY_CLASSES_ROOT, '.txt', windef.KEY_ACCESS.KEY_ALL_ACCESS);
@@ -91,9 +96,11 @@ The return value depends on the type of the key (REG_SZ for example will give yo
91
96
To launch a process as an Administrator, you can call the `uac.elevate` api, which will launch a process as an Administrator causing the UAC (User Account Control) elevation prompt to appear if required. This is similar to the Windows Explorer command "Run as administrator". Pass in `FILEPATH` to the process you want to elevate. Pass in any`PARAMETERS` to run with the process. Since this is an asychronous call, pass in a callback to handle user's selection.
92
97
93
98
```js
99
+
var uac =require('windows-registry').uac;
94
100
uac.elevate('C:\\Program Files\\nodejs\\node.exe', 'index.js', function (err, result){console.log('callback');});
95
101
```
96
102
97
103
## More Docs?
98
104
99
105
Make your way over to the [tests section](test) to see how the module can be used.
0 commit comments