sys.registry.read(root, key, isexpanded)
Read a value associated with the provided key, in the Windows registry.
Parameters
rootkey
Indicates the predefined entry point in the Windows registry, from which the key/value will be accessed. Must be one of the following string :
- "HKEY_CLASSES_ROOT" : types (or classes) of documents and the properties associated with those types
- "HKEY_CURRENT_CONFIG" : information about the current hardware
- "HKEY_CURRENT_USER" : preferences of the current user
- "HKEY_LOCAL_MACHINE" : data about the computer, system memory, and installed hardware and software
key
Indicates the name of the key with which the value is associated.
isexpanded
Indicates if environment strings should be expanded or not (defaults to false
). Registry values may contains references to environment variables (for example, %PATH%
). Expanding those references replaces them with their current value.
Return value
This function returnsnil
if the value cannot be found, or returns the registry value according to the following conversion rules :
Registry value type | Lua value type |
---|---|
REG_BINARY |
Buffer |
REG_QWORD REG_DWORD |
number |
REG_SZ REG_EXPAND_SZ |
string |
REG_LINK |
string |
REG_MULTI8SZ |
table of strings |
REG_NONE |
|
Example
local cpu = sys.registry.read("HKEY_LOCAL_MACHINE", "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "ProcessorNameString")
print("[ CPU ]", cpu)