InstallShield 2016 ยป InstallScript Language Reference
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 OpenFileMode function.
*
* This script opens a text file in read-only (FILE_MODE_NORMAL)
* mode. It then retrieves and displays the first line from
* the file.
*
* Next, it opens a file in binary mode, positions the file
* pointer at the 15th byte and reads 28 bytes from the file.
*
* Note: In order for this script to run correctly, you must set
* the preprocessor constants so that they reference
* existing files in an existing directory.
*
\*--------------------------------------------------------------*/
#define EXAMPLE_DIR "C:\\"
#define EXAMPLE_TEXT_FILE "ISExampl.txt"
#define EXAMPLE_BIN_FILE "ISExampl.bin"
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_OpenFileMode(HWND);
function ExFn_OpenFileMode(hMSI)
STRING svLine, svString;
NUMBER nvFileHandle;
begin
// Set the file mode to normal.
OpenFileMode (FILE_MODE_NORMAL);
// Open the file.
if (OpenFile (nvFileHandle, EXAMPLE_DIR, EXAMPLE_TEXT_FILE) < 0) then
MessageBox ("OpenFile failed.", SEVERE);
abort;
endif;
// Get the first line of the text file.
GetLine (nvFileHandle, svLine);
// Display the line.
MessageBox (svLine, INFORMATION);
// Close the file.
CloseFile (nvFileHandle);
// Set the file mode to binary read/write.
OpenFileMode (FILE_MODE_BINARY);
// Open the file.
if (OpenFile (nvFileHandle, EXAMPLE_DIR, EXAMPLE_BIN_FILE) < 0) then
MessageBox ("OpenFile failed.", SEVERE);
else
// Move the file pointer to byte 15.
SeekBytes (nvFileHandle, 15, FILE_BIN_START);
// Read 28 bytes from the binary file into svString.
if (ReadBytes (nvFileHandle, svString, 0, 28) < 0) then
MessageBox ("ReadBytes failed.", SEVERE);
else
// Display the string.
MessageBox (svString, INFORMATION);
endif;
// Close the binary file.
CloseFile (nvFileHandle);
endif;
end;
InstallShield 2016 Help LibraryMay 2017 |
Copyright Information | Flexera Software |