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;
HKLM
HKCU
HKCR
HKU
HKCC
HKEY_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);
Per default the type of the value written is String
, however you can specify the type to use explicitly:
js
Registry
.HKCU
.open("Software/Sirenia/Manatee/Ports")
.write("websocketserversecureselfsigned", 12345, "dword");
The following strings can be used as registry type:
"binary"
"string"
"unknown"
"none"
"dword"
"qword"
"expandstring"
"multistring"