ReplaceProfString

InstallShield 2020 ยป InstallScript Language Reference

In Windows Installer based projects, all .ini file changes should be created in the INI Files view of the IDE. Handling all of your .ini file changes in this way allows for a clean uninstallation through the Windows Installer service.

The ReplaceProfString function replaces a profile string in an .ini file. This function can replace values of duplicate keys (non-unique keys) such as those found in the [386Enh] section of the System.ini file (device = ...). The function searches for a szKeyName = szOrigValue, and replaces the line. If it is not found, it adds the szKeyName = szReplaceValue line to the beginning of the szSectionName section.

If you are adding unique keys (that is, keys that are all different for a given section), use the WriteProfString function.

Use this function to replace only non-unique key names, such as the device= line in the System.ini file.

Syntax

ReplaceProfString ( szFileName, szSectionName, szKeyName, szOrigValue, szReplaceValue );

Parameters

ReplaceProfString Parameters

Parameter

Description

szFileName

Specifies the name of the .ini file in which the profile string is to be replaced. If the file name is unqualified (that is, if a drive designation and path are not included), InstallShield searches for the file in the Windows folder. If the file does not exist, it is created in the specified folder; if a path is not included in file name, the file is created in the Windows folder. Note that if the file name is qualified with a path that does not exist, ReplaceProfString will fail.

szSectionName

Specifies the name of the .ini file section to search for szKeyName. The section name should not be enclosed within delimiting brackets ( [ ] ). The search for this name is not case sensitive.

szKeyName

Specifies the name of the key to replace. If the key does not exist, it is created.

szOrigValue

Specifies the current value of the key specified by szKeyName.

szReplaceValue

Specifies the new value to assign to szKeyName. The value of this parameter will appear to the right of the equal sign in the profile string (szKeyName = szValue).

Return Values

ReplaceProfString Return Values

Return Value

Description

0

Indicates that the function successfully replaced or added the profile string.

< 0

Indicates that the function was unable to replace or add the profile string.

Additional Information

Changes made to .ini files can be logged for uninstallation. However, there are some important restrictions to be aware of. For more information, see Uninstalling Initialization (.ini) File Entries.

See Also