# Scripting: Windows Registry Functions

> Functions for reading and writing to the Windows Registry. How to check license keys or system settings directly from a protection script.

Canonical HTML: <https://www.niceprotect.com/help/registry.htm>

## Registry Commands


The subkey and the value name are given together in a single parameter, separated by a backslash; the part after the last backslash is the value name.

**registry.set** <root>, <subkey\name>, <type>, <value> - Writes a value to the registry. <type> is REG_DWORD for an integer, otherwise a string is written.

**registry.get** <root>, <subkey\name>, <accumulator> - Reads a value from the registry into the accumulator (empty if the value does not exist).


Example:

**registry.set** HKCU, Software\MyApp\Build, REG_DWORD, 42

**registry.get** HKCU, Software\MyApp\Build, _build

**Root Key Constants:**


HKCR or &H80000000 - HKEY_CLASSES_ROOT

HKCU or &H80000001 - HKEY_CURRENT_USER

HKLM or &H80000002 - HKEY_LOCAL_MACHINE

HKU   or &H80000003 - HKEY_USERS

HKPD or &H80000004 - HKEY_PERFORMANCE_DATA

HKCC or &H80000005 - HKEY_CURRENT_CONFIG

HKDD or &H80000006 - HKEY_DYN_DATA
