WriteLine Example
InstallShield 2024 » 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 CreateFile and WriteLine functions.
*
* Createfile is called to create a file to store a string. The
* string is written into the file by the WriteLine function.
*
* Note: Before running this script, set the preprocessor
* constant EXAMPLE_DIR so that it references an existing
* directory on the target system. Note that if the file
* specified by EXAMPLE_FILE already exists, it will be
* overwritten.
*
\*--------------------------------------------------------------*/
#define EXAMPLE_DIR "C:\\"
#define EXAMPLE_FILE "ISExampl.txt"
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_WriteLine(HWND);
function ExFn_WriteLine(hMSI)
STRING szTitle, szMsg;
NUMBER nvFileHandle;
begin
// Set the file mode to append.
OpenFileMode (FILE_MODE_APPEND);
// Create a new file and leave it open.
if (CreateFile (nvFileHandle, EXAMPLE_DIR, EXAMPLE_FILE) < 0) then
// Report the error.
MessageBox ("CreateFile failed.", SEVERE);
abort;
else
// Set the message to write to the file.
szMsg = "This line was appended by an example InstallShield script.";
// Append the message to the file.
if (WriteLine(nvFileHandle, szMsg) < 0) then
// Report the error.
MessageBox ("WriteLine failed.", SEVERE);
else
// Report success.
szTitle = "CreateFile & WriteLine";
szMsg = "Successfully created and wrote to %s.";
SprintfBox (INFORMATION, szTitle, szMsg, EXAMPLE_FILE);
endif;
endif;
// Close the file.
CloseFile (nvFileHandle);
end;