Registry
The Registry module is used to access the Windows registry for reading/writing of data.
You start by accessing one of the root keys which are properties of the Registry module;
HKLMHKCUHKCRHKUHKCCHKEY_PERFORMANCE_DATA
these then return a JsRegistryKey with the following properties:
name(string) The name of the key.valueNames(string[]) A list of the names of values stored at this key.subkeys(string[]) A list of the names of subkeys stored under this key.
The JsRegistryKey then has the following methods:
Open
To open a subkey. Supply the path the key (delimited by “/”), e.g.
js
var k = Registry.HKCU.open("Software/Sirenia/Manatee/Ports");Read
To read the value stored at the given name, e.g.
js
var port = Registry
.HKCU
.open("Software/Sirenia/Manatee/Ports")
.read("websocketserversecureselfsigned");Delete
To delete a subkey or a whole subkeytree, e.g.
js
// Delete the Manatee subkey
Registry
.HKCU
.open("Software/Sirenia/Manatee/Ports")
.delete("websocketserversecureselfsigned");
// To delete the whole subtree
Registry
.HKCU
.open("Software/Sirenia/Manatee")
.delete("Ports", { subtree: true });Write
Write a new value to the name of the key, e.g.
js
Registry
.HKCU
.open("Software/Sirenia/Manatee/Ports")
.write("websocketserversecureselfsigned", 12345);Options
The write method additionally accepts an options object as a third argument. The following options are available:
kind(string) The type of the value to write. Default is"string".
The following strings can be used as registry type:
"binary""string""unknown""none""dword""qword""expandstring""multistring"
createMissingKeys(boolean) Iftrue, missing keys in the opened path will be created before carrying out the write operation. Default isfalse.
js
Registry
.HKCU
.open("Software/Sirenia/Manatee/Ports")
.write("websocketserversecureselfsigned", 12345, { kind: "dword", createMissingKeys: true });