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 WriteBytes function.
*
* WriteBytes is called to write a company name to a binary file.
*
* Note: Before running this script, set the preprocessor
* constants so that they reference an existing directory
* and file on the target system. Because the script will
* write to this file -- overwriting any existing data --
* you should create a file or make a copy of an existing
* file for use with this example.
*
\*--------------------------------------------------------------*/
#define EXAMPLE_DIR "C:\\"
#define EXAMPLE_FILE "ISExampl.bin"
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_WriteBytes(HWND);
function ExFn_WriteBytes(hMSI)
STRING szQuestion, svCompany[28];
NUMBER nFileHandle, nOffset, nIndex, nBytes;
begin
// Set the file open mode.
OpenFileMode (FILE_MODE_BINARY);
// Open the file and get the file handle.
if (OpenFile (nFileHandle, EXAMPLE_DIR, EXAMPLE_FILE) < 0) then
MessageBox ("Unable to open the file.", SEVERE);
abort;
endif;
// Ask user for his or her company name.
szQuestion = "Please enter your company name. You may enter up to " +
"twenty-seven characters.";
AskText (szQuestion, "My Software Company", svCompany);
// Move the file pointer 15 bytes from the start of the file.
nOffset = 15;
SeekBytes (nFileHandle, nOffset, FILE_BIN_START);
// Write the company name to the file.
nIndex = 0;
nBytes = 27;
if (WriteBytes (nFileHandle, svCompany, nIndex, nBytes) < 0) then
MessageBox ("WriteBytes failed.", SEVERE);
else
MessageBox ("Bytes successfully written to file.", INFORMATION);
endif;
// Close the file.
CloseFile (nFileHandle);
end;
InstallShield 2016 Help LibraryMay 2017 |
Copyright Information | Flexera Software |