WriteProfInt Example

InstallShield 2016 » 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 WriteProfInt function.

*

* This script updates an integer value 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  "OurAppVal"

#define    KEYVAL   0

 

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

#include "Ifx.h"

 

export prototype ExFn_WriteProfInt(HWND);

 

function ExFn_WriteProfInt(hMSI)

begin

 

    // Update a field in the initialization file.

    if (WriteProfInt (EXAMPLE_INI, SECTION, KEYNAME, KEYVAL)  < 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;