Update INI File Section

The Update INI File section replaces, deletes, or adds complete entries in the INI file. The section name, update-ini-section-name, must appear in the UpdateInis item in the Install section of the INF file.

[update-ini-section-name]

ini-file,ini-section,[old-ini-entry],[new-ini-entry],[flags]

.

.

.

ini-file

The INI file containing the entry to change.

ini-section

Name of the section containing the entry to change.

old-ini-entry

Optional. Usually in the form key=value.

new-ini-entry

Optional. Usually in the form key=value. Either the key or value may specify replaceable strings. For example, either the key or value specified in the new-ini-entry parameter may be %String1%, where the string that replaces %String1% is defined in the Strings section of the INF file.

flags

Optional action flags. The flags parameter can be one of these values:

Value Meaning
0 Default. If old-ini-entry key is present in an INI file entry, that entry is replaced with new-ini-entry. Only the keys of the old-ini-entry parameter and the INF file entry must match; the value of each entry is ignored.

To add new-ini-entry to the INI file unconditionally, set old-ini-entry to NULL. To delete old-ini-entry from the INI file unconditionally, set new-ini-entry to NULL.

1 If both key and value of old-ini-entry exist in an INI file entry, that entry is replaced with new-ini-entry. The old-ini-entry parameter and the INF file entry must match on both key and value for the replacement to be made (this is in contrast to using an action flag value of 0, where only the keys must match for the replacement to be made).
2 If the key in the old-ini-entry parameter does not exist in the INI file, then no operation is performed on the INI file.

If the key in the old-ini-entry parameter exists in an INI file entry and the key in the new-ini-entry parameter exists in an INI file entry, the INI file entry that matches the key in the new-ini-entry parameter is deleted, and the key of the INI file entry that matches the old-ini-entry parameter is replaced with the key in the new-ini-entry parameter.

If the key in the old-ini-entry parameter exists in an INI file entry and the key in the new-ini-entry parameter does not exist in an INI file entry, an entry made up of the key in the new-ini-entry parameter and the old value is added to the INI file.

The match of the old-ini-entry parameter and an INI file entry is based on key alone, not key and value.

3 Same as flags parameter value of 2 described above, except the match of the old-ini-entry parameter and an entry in the INF file is based on matching both key and value, not just the key.

The wild card character (*) can be used in specifying the key and value and they will be interpreted correctly.

The ini-file name can be a string or a strings key. A strings key has the form %strkey% where strkey is defined in the Strings section in the INF file. The name must be a valid filename.

The ini-file name should include the name of the directory containing the file, but the directory name should be given as a DIRID rather than an actual name. The installer replaces a DIRID with an actual name during installation.

A DIRID has the form %dirid% where dirid is one of the predefined identifiers or a user-defined by a call to the SetupSetDirectoryId function. When using a DIRID, you should use the backslash in a path. For example, %11%\card.ini can be used to reference card.ini in the system32 directory.

The following examples illustrate individual items in an Update INI File section:

%11%\sample.ini, Section1,, Value1=2 ; adds new entry

%11%\sample.ini, Section2, Value3=*, ; deletes old entry

%11%\sample.ini, Section4, Value5=1, Value5=4 ; replaces old entry