WriteProfString Example

InstallShield 2019 » InstallScript Language Reference

Note • To call this function in a Basic MSI setup, you must first create a custom action for the entry-point function, execute the custom action in a sequence or as the result of a dialog's control event, and then build the release.

/*--------------------------------------------------------------*\

*

* InstallShield Example Script

*

* Demonstrates the WriteProfString function.

*

* This script updates a field in an initialization file in the

* Windows directory.  If the file does not exist, it is created.

*

\*--------------------------------------------------------------*/

 

// Define the initialization file name.

#define EXAMPLE_INI WINDIR ^ "ISExampl.ini"

 

// Define the initialization item and its new value.

#define    SECTION  "Windows"

#define    KEYNAME  "Keyboard"

#define    KEYVALUE "English"

 

// Include Ifx.h for built-in InstallScript function prototypes.

#include "Ifx.h"

 

export prototype ExFn_WriteProfString(HWND);

 

function ExFn_WriteProfString(hMSI)

begin

 

    // Update a field in the initialization file.

    if (WriteProfString (EXAMPLE_INI, SECTION, KEYNAME, KEYVALUE) < 0) then

        // Report the error.

        SprintfBox (SEVERE, "WriteProfString",

                   "%s could not be updated", EXAMPLE_INI);

    else

        // Report success.

        SprintfBox (INFORMATION, "WriteProfString", "%s was modified.", EXAMPLE_INI);

    endif;

 

end;