FReplaceStr function

Replace text strings in a text file. Handles ANSI, Unicode UTF-8, and Unicode UTF-16 encoded plain text files, including HTML and XML files.

The FReplaceStr function is a predefined extension DLL function that is distributed with InstallMate. You can use this function by adding a Run DLL action to the action sequence in which you want to run the action. Set the Run DLL action attributes as follows:

Arguments

The FReplaceStr function expects the following arguments. All arguments may contain symbolic references; these will be resolved before the function is called. Note that you must "quote" an argument if it contains spaces, or if it could contain spaces after expansion of symbolic references.

filepath
The fully qualified file path of the text file that must be processed, for example "<INSTALLDIR>\Sample.txt".
search
The text string to search for, for example "MyHomePath". Text matching is case-insensitive.
replace
The text string that replaces each occurrence of the search string, for example "<INSTALLDIR>".
flags
[Optional] One of the following:
0 - Treat the filepath file as a generic text file while processing (the default)
1 - Treat the filepath file as an XML file while processing
2 - Treat the filepath file as an HTML file while processing

Return value

Returns ERROR_SUCCESS (zero) if successful, else a nonzero error code. This error code is available in the LastExitCode variable.

Remarks

To use this function, you must add the extension DLL to your InstallMate project. The easiest way to do so is as follows:

  1. Open your InstallMate project.
  2. Choose File > Import > Project Items... from the main menu bar.
  3. Browse for and select the file Insert Extension DLL.imq, then click Open.

Alternatively, you can go to the Installer options page in your InstallMate project, click on the Advanced... button, then click on the Extension DLL tab and enter the paths to the extension DLL versions there.