Skip to content

Commit 7e937e5

Browse files
author
abhimanyu-bst
committed
Added delete value method
1 parent e7fe301 commit 7e937e5

File tree

5 files changed

+2186
-7
lines changed

5 files changed

+2186
-7
lines changed

lib/key.js

+7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ class Key {
3535
this._registry.deleteKey(this);
3636
}
3737

38+
/**
39+
* Deletes a value from a key
40+
*/
41+
deleteValue (value) {
42+
this._registry.deleteValue(this, value);
43+
}
44+
3845
/**
3946
* Sets a value for a value name on this key
4047
* all the containers matching the query.

lib/native/adv_api.js

+8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ var advApi = ffi.Library('Advapi32', {
6666
);
6767
*/
6868
RegDeleteTreeA: ['long', [types.HKEY, 'string']],
69+
/*
70+
LONG WINAPI RegDeleteValue(
71+
_In_ HKEY hKey,
72+
_In_opt_ LPCTSTR lpValueName
73+
);
74+
*/
75+
76+
RegDeleteValueA: ['long', [types.HKEY, 'string']],
6977
/*
7078
LONG WINAPI RegCloseKey(
7179
_In_ HKEY hKey

lib/registry.js

+7
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ var api = {
136136
throw 'Failed to open key error ' + result + ':' + error[result];
137137
}
138138
},
139+
deleteValue: function (key, value) {
140+
var result = advApi.RegDeleteValueA(key.handle.deref(), value);
141+
142+
if (result !== 0) {
143+
throw 'Failed to delete value error ' + result + ':' + error[result];
144+
}
145+
},
139146
closeKey: function (key) {
140147
var result = advApi.RegCloseKey(key.handle.deref());
141148

0 commit comments

Comments
 (0)