Introduction
A .reg file is a text listing of keys and values from the
Windows Registry, the database where
Windows and its programs keep their settings. Registry Editor writes one when a key is
exported, and opening a .reg file merges its contents back into the
Registry, after a warning.
Because merging a file can change any setting on the machine, .reg files
from unknown sources should be read before they are opened. The Registry itself is
stored in binary hive files, which are a different format: see
.REGF, the Windows registry hive.
Structure
Files written by current versions of Registry Editor are UTF-16 text and start with
the line Windows Registry Editor Version 5.00. Older files start with
REGEDIT4 and use the ANSI code page.
Each key appears as its full path in square brackets (see
syntax and value types), followed by its values, one per
line. A value is a quoted name, or @ for the key’s default value, an equals
sign and the data: a quoted string, dword: and eight hexadecimal digits, or
hex: and a list of bytes. Other types are written as
hex(type):, such as hex(2): for an
expandable string and hex(7): for a list of strings. A value of
- deletes the value, and a minus sign before a key’s path,
[-HKEY_…], deletes the whole key.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Example]
"Name"="Text value"
"Count"=dword:00000010
"Old"=-
Not described
Known, not yet covered
- Viewer: the viewer reads both headers, keys, deletions, every value form
(
"text",dword:,hex:,hex(n):) with the data decoded by type, line continuations and escapes, and lists every problem with its line. The bytes ofREG_RESOURCE_LIST,REG_FULL_RESOURCE_DESCRIPTORandREG_RESOURCE_REQUIREMENTS_LISTvalues are shown as hex, not decoded into resource descriptors.
Unknown
- Reference: how Windows’ own Registry Editor escapes strings, wraps long
hexlists and writes thehex(n)forms: Microsoft’s KB 310516 does not define them, so the pages give Wine’s behaviour (syntax). The viewer reads the same way: a backslash that is not\\or\"in a string is reported and kept, and a line ending in a backslash continues only forhexvalues. Microsoft’s support article was not fetched as a raw page, so it is cited by its number, KB 310516.
Links
Software
- Registry Editor (regedit) – built into Windows, exports and merges .reg files (Windows)
- reg – command-line tool built into Windows, whose
reg exportandreg importcommands write and read them (Windows) - Notepad – or any text editor, to read a .reg file before merging it (Windows)
Reference
- .REGF Windows registry hive – the binary files the Registry is stored in (NTUSER.DAT, SYSTEM, SOFTWARE, SAM)