ConfigAdd

InstallShield 2024 » InstallScript Language Reference

The ConfigAdd function adds a statement to the system configuration file that has been loaded into memory with ConfigFileLoad. You can specify the position of the statement relative to a reference key, or you can add the statement as the first or last line of the file. You can also replace an existing line in the file.

Note:Before calling ConfigAdd, you must first call ConfigFileLoad to load the system configuration file into memory. After you edit the file, call ConfigFileSave to save the file.

Do not mix the Ez configuration file functions with the advanced configuration file functions. After calling ConfigFileLoad, you cannot use the Ez configuration file functions until you call ConfigFileSave to save your changes.

Syntax

ConfigAdd ( szKey, szValue, szRefKey, nOptions );

Parameters

ConfigAdd Parameters

Parameter

Description

szKey

Specifies the keyword in the statement that is being added to the system configuration file.

szValue

Specifies the value of the keyword that is being added to the system configuration file.

szRefKey

Specifies the reference key relative to which you are adding szKey in the system configuration file. If you pass a null string ("") in this parameter, the line is added as the first or last line in the file, depending on which predefined constant is passed in nOptions.

nOptions

Specifies whether the line is to be added before or after the line containing the reference key, or whether the line replaces an existing line. Pass one of the following predefined constants in this parameter:

BEFORE—The statement is added before the line containing szRefKey. If szRefKey is a null string (""), the statement is added as the first line of the file.
AFTER—The statement is added after the line containing szRefKey. If szRefKey is a null string (""), the statement is added as the last line of the file.
REPLACE—The statement replaces an existing line in the file. If multiple lines with same key exist, only the last line is replaced. If a line to be replaced does not exist in the file, the new line is added as the last line of the file.

Return Values

ConfigAdd Return Values

Return Value

Description

0

ConfigAdd successfully added the statement to the specified system configuration file.

< 0

ConfigAdd was unable to add the statement to the specified system configuration file.

Additional Information

When the ConfigAdd function replaces a line in a system configuration file, it compares the reference keys in the two lines. A reference key is a substring that identifies the line. For example, in the following statement, the reference key is Kybrd.drv.

   DEVICE=C:\Windows\System\Kybrd.drv /1024 /C:345

In the next statement, the reference key is PATH:

   SET PATH=C:\Windows;C:\Windows\System

See Also