Sprintf 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 Sprintf function.

*

* This script gets the capacity of drive C: and then calls

* Sprintf to create a formatted message.  That message

* includes the drive letter and disk size, which are stored

* in variables.  The message is then displayed.

*

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

 

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

#include "Ifx.h"

 

export prototype ExFn_Sprintf(HWND);

 

function ExFn_Sprintf(hMSI)

    STRING  svResult, svMssg;

    NUMBER  nvResult;

begin

 

    // Set up the string parameter for the call to GetSystemInfo.

    svResult = "C:";

    

    // Get the capacity of drive C.

    GetSystemInfo (DISK_TOTALSPACE, nvResult, svResult);

    

    // Build a message that incorporates the values

    // returned by GetSystemInfo.

    Sprintf (svMssg, "Total disk space on drive %s is %ld bytes.",

            svResult, nvResult);

    

    // Display the message.

    MessageBox (svMssg, INFORMATION);

 

end;