Add Registry Section

The Add Registry section adds subkeys or value names to the registry, optionally setting the value. The add-registry-section name must appear in an AddReg item in an Install section.

[add-registry-section]
reg-root-string, [subkey], [value-name], [flags], [value]
[reg-root-string, [subkey], [value-name], [flags], [value]]
.
.
.
 
reg-root-string
Registry root name. Can be one of these values:

HKCR

Same as HKEY_CLASSES_ROOT.

HKCU

Same as HKEY_CURRENT_USER.

HKLM

Same as HKEY_LOCAL_MACHINE.

HKU

Same as HKEY_USERS.

HKR

Relative to the key passed into SetupInstallFromInfSection.

subkey
Optional. Identifies the subkey to set. Has the form key1\key2\key3....
value-name
Optional. Identifies the value name for the subkey. For string type, if the value-name parameter is left empty, the default value in the key is set.
flag
Optional. Establishes the value data type and the AddReg item action. The flag value is a bit map where the low word contains basic flags that define the general data type and AddReg item action. The high word contains values that more specifically identify the data type of the registry value. The high word is ignored by the 16-bit Windows 95 Setup functions provided by the Setupx DLL. The flags are defined as follows:
FLG_ADDREG_BINVALUETYPE
(0x00000001)
The value is “raw” data.
FLG_ADDREG_NOCLOBBER
(0x00000002)
Do not write over the registry key if it already exists.
FLG_ADDREG_DELVAL
(0x00000004)
Delete the value from the registry.
FLG_ADDREG_APPEND
(0x00000008)
Append a value to an existing value. This flag is currently supported only for REG_MULTI_SZ values.
FLG_ADDREG_TYPE_MASK
(0xFFFF0000 | FLG_ADDREG_BINVALUETYPE)
Mask.
FLG_ADDREG_TYPE_SZ (0x00000000)
Registry data type REG_SZ.
FLG_ADDREG_TYPE_MULTI_SZ
(0x00010000)
Registry data type REG_MULTI_SZ.
FLG_ADDREG_TYPE_EXPAND_SZ
(0x00020000)
Registry data type REG_EXPAND_SZ.
FLG_ADDREG_TYPE_BINARY
(0x00000000 | FLG_ADDREG_BINVALUETYPE)
Registry data type REG_BINARY.
FLG_ADDREG_TYPE_DWORD
(0x00010000 | FLG_ADDREG_BINVALUETYPE)
Registry data type REG_DWORD.
FLG_ADDREG_TYPE_NONE
(0x00020000 | FLG_ADDREG_BINVALUETYPE)
Registry data type REG_NONE.

Bit 0 of the flag distinguishes between character and binary data as it does in the Windows 95 Setup functions, thus a Windows 95 installation program will see the extended data types as REG_SZ or REG_BINARY. To allow REG_DWORD entries to be compatible with both operating systems, the following formats are supported:

  • Non-compatible format. If compatibility with Windows 95 Setup functions is not required, a REG_DWORD entry can contain a single data value field. This value can be prefixed with a sign and be either decimal or hexadecimal. For example:

    HKLM,"Software\Microsoft\Windows NT\CurrentVersion\FontDPI","LogPixels",0x10001,120
     

  • Windows 95 compatible format. If compatibility with Windows 95 Setup functions is required, the data of a FLG_ADDREG_TYPE_DWORD entry must be formatted like a REG_BINARY entry. The Windows NT Setup functions recognize a REG_DWORD line with exactly four data elements as conforming to this format. The Setup functions interpret the four data elements as one DWORD. Hexadecimal number fields are only supported by the Windows 95 Setup functions as members of a REG_BINARY data list, in which case the data is assumed to be in hexadecimal format (the 0x prefix must not be used). The example listed above can be written in Windows 95-compatible format as follows:

    HKLM,"Software\Microsoft\Windows NT\CurrentVersion\FontDPI","LogPixels", 65537,78,0,0,0
     
To represent a number with a data type other than the predefined REG_* types, you can specify the type number in the flag's high word and specify binary type in its low word. You must enter the data in binary format, one byte per field. For example, to store 16 bytes of data with a new data type of 0x38, you would have an AddReg item as follows:
HKR,,MYValue,0x00380001,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
 

This technique may be used with any data type except REG_EXPAND_SZ, REG_MULTI_SZ, REG_NONE, and REG_SZ.

value
Optional. Value to set. Can be either a string or a number in hexadecimal notation. At least two fields are required; however, one can be null. Therefore, at least one comma is required when using this form.

The two items in the example Add Registry section below, which is named sermouse_EventLog_AddReg, add two value names to the registry, EventMessageFile and TypesSupported, and set the value of these names.

[sermouse_EventLog_AddReg]
HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\IoLogMsg.dll;%%SystemRoot%%\System32\drivers\sermouse.sys"
HKR,,TypesSupported,0x00010001,7