CopyBytes Example

InstallShield 2020 ยป 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 CopyBytes function.

*

* This example script retrieves the current date from the

* target system.  Then, it copies the year from the date and

* displays the year to the end user.

*

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

 

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

#include "Ifx.h"

 

export prototype ExFn_CopyBytes(HWND);

 

function ExFn_CopyBytes(hMSI)

    STRING svDate, svYear;

    NUMBER nvResult, nIndexDate, nIndexYear, nCount;

begin

 

    // Get the date from the target system.

    GetSystemInfo (DATE, nvResult, svDate);

    

    // Set up parameters to pass to CopyBytes. The year is

    // in the last four bytes of svDate.

    nIndexYear  = 0;

    nCount      = 4;

    nIndexDate  = StrLength(svDate) - nCount;

    

    // Copy the four bytes representing the year into svYear.

    if (CopyBytes (svYear, nIndexYear, svDate, nIndexDate, nCount) < 0) then

        // Report an error.

        MessageBox ("CopyBytes failed.", SEVERE);

    else

        // Display the year.

        MessageBox ("The year is " + svYear, INFORMATION);

    endif;

 

end;