Identifying the Elements of a Reg File
As you review the examples shown in the two figures, note the following characteristics of .reg files:
• Header line The file begins with the line Windows Registry Editor Version 5.00.
When you merge a .reg file into the registry, Registry Editor uses this line to verify that the file contains registry data. Version 5 (the version shipped with Windows 7) generates Unicode text files, which can be used in Windows XP, Windows 2000, and Windows Vista, as well as Windows 7 . If you want to share registry data with a system running Windows 95/98/Me or Windows NT, select the Win9x/NT4 Registration Files option when you export the file in Registry Editor. To create from scratch a .reg file that's suitable for import into Windows 95/98/Me or Windows NT, use the header REGEDIT4 instead of Windows Registry Editor Version 5.00.
• Key names Key names are delimited by brackets and must include the full path from the root key to the current subkey. The root key name must not be abbreviated . (Don't use HKCU, for example.) Figure 22-21 shows only one key name, but you can have as many as you please.
• The default value Undefined default values do not appear in .reg files. Defined default values are identified by the special character @. Thus, a key whose default REG_SZ value was defined as MyApp would appear in a .reg file this way: "@"="MyApp"
• Value names Value names must be enclosed in quotation marks, whether or not they include space characters . Follow the value name with an equal sign.
• Data types REG_SZ values don't get a data type identifier or a colon . The data directly follows the equal sign. Other data types are identified as shown in Table 22-2:
|
Data Type |
Identifier |
|
REG_BINARY |
hex |
|
REG_DWORD |
dword |
|
REG_QWORD |
hex(b) |
|
REG_MULTI_SZ |
hex(7) |
|
REG_EXPAND_SZ |
hex(2) |
A colon separates the identifier from the data. Thus, for example, a REG_DWORD value named Keyname with value data of OOOOOOOO looks like this:
"Keyname"=dword:00000000
• REG_SZ values Ordinary string values must be enclosed in quotation marks. A backslash character within a string must be written as two backslashes. Thus, for example, the path C:\Program Files\Microsoft Office\ is written like this:
"C:\\Program Files\\Microsoft Office\\"
• REG_DWORD values DWORD values are written as eight hexadecimal digits, without spaces or commas Do not use the Ox prefix
• All other data types All other data types—including REG_EXPAND_SZ, REG_MULTI_ SZ, and REG_QWORD—appear as comma-delimited lists of hexadecimal bytes (two hex digits, a comma, two more hex digits, and so on). The following is an example of a REG_MULTI_SZ value:
"Addins"=hex(7):64,00,3a,00,5c,00,6c,00,6f,00,74,00,00,75,00,73,00,5c,00,\
31,00,32,00,33,00,5c,00,61,00,64,00,64,00,64,00,69,00,6e,00,73,00,5c,00,\
64,00,71,00,61,00,75,00,69,00,2e,00,31,00,32,00,61,00,00,00,00,00,00,00
• Line-continuation characters You can use the backslash as a line-continuation character. The REG_MULTI_SZ value just shown, for example, is all one stream of bytes . We've added backslashes and broken the lines for readability, and you can do the same in your .reg files .
• Line spacing You can add blank lines for readability. Registry Editor ignores them.
• Comments To add a comment line to a .reg file, begin the line with a semicolon.
Post a comment