Add Registry Section


AddReg

[DefaultInstall]
AddReg=AddRegSection

[AddRegSection]
reg-root-string,(subkey),(value-name),(flag),(value)
2nd-reg-root-string,(subkey),(value-name),(flag),(value)

Adds subkeys or value names to the registry, optionally setting the value. The AddRegSection name must appear in an AddReg-type item in an Install section such as DefaultInstall.

reg-root-string
Registry root name. Can be one of these values:

subkey
Optional. Identifies the subkey to set. Has the form key1\key2\key3.... This parameter can be expressed as a replaceable string. For example, you could use %Subkey1% where the string to replace %Subkey1% is defined in the Strings section of the INF file.

value-name
Optional. Identifies the value name for the subkey. For string type, if the value-name parameter is left empty, the value of the subkey specified in the subkey parameter is set to a NULL string. Note that the value-name parameter can be expressed as a replaceable string. For example, you could use %Valname1% where the string to replace %Valname1% is defined in the Strings section of the INF file.

flag
Optional. Determines both the value type and whether the registry key is replaced if it already exists.

Value Meaning
0 (Default) Value is an ANSI string. Replace key if it exists.
1  Value is a hexadecimal number. Replace key if it exists.
2  Value is an ANSI string. Do not replace key if it exists.
3 Value is a hexadecimal number. Do not replace key if it exists.


value
Optional. Value to set. Can be either an ANSI string or a number in hexadecimal notation and Intel format. Any item containing a binary value can be extended beyond the 128-byte line maximum by using a backslash (\) character. A string key of the form %strkey% can also be given. The strkey must be defined in the Strings section of the INF file. To use a % character in the line, use %%.

At least two fields are required, however one can be null thus at least one comma is required when using this form.

The two items in the example AddReg-type section below add two value names to the registry. Note that %25% will be expanded to the machine's Windows directory.

[MyAppRegEntries]
HKLM,Software\MyApp,ProgramName,,"My Application"
HKLM,Software\MyApp,"Program Location",,"%25%\MyApp.exe"

Note: Using an INF there is not a way to add dwords in Windows 95/98/ME, but there is a way to trick the system to believe that you did:

Set a binary key to the value of 01,00,00,00. This will reflect the same as a dword of one.