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 UseDLL and the UnUseDLL functions.
*
* UseDLL is called to load an example .dll file into memory. A
* function in this .dll file is then called to demonstrate how
* .dll functions can be used in an installation. Finally,
* UnUseDLL is called to unload the example .dll file from memory.
*
* Note: This script requires that the constant DLL_FILE be set
* to the fully qualified name of a .dll file that contains
* a function called TheExportedFunction. The format of that
* function must match the prototype declaration below.
*
\*--------------------------------------------------------------*/
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
#define DLL_FILE SUPPORTDIR ^ "TheDLL.dll"
// Prototype TheExportedFunction in TheDLL.dll.
prototype TheDLL.TheExportedFunction (INT, WPOINTER);
export prototype ExFn_UnUseDLL(HWND);
function ExFn_UnUseDLL(hMSI)
STRING svString;
INT nValue;
WPOINTER psvString;
NUMBER nResult;
BOOL bDone;
begin
// Load the .dll file into memory.
nResult = UseDLL (DLL_FILE);
if (nResult = 0) then
MessageBox ("UseDLL successful \n\n.dll file loaded.", INFORMATION);
else
MessageBox ("UseDLL failed.\n\nCouldn't load .dll file.", INFORMATION);
abort;
endif;
// bDone controls the following while loop.
bDone = FALSE;
// Loop while bDone is FALSE.
while (bDone = FALSE)
// Disable the Back button in installation dialogs.
Disable (BACKBUTTON);
// Get a string from the user.
AskText ("Enter an example string.", "Example string.", svString);
// Get a pointer to the string to pass to TheExportedFunction.
psvString = &svString;
// Get the string length to pass to TheExportedFunction.
nValue = StrLength (svString);
// Call TheExportedFunction.
TheExportedFunction (nValue, psvString);
// Display the string to observe how it was altered by TheExportedFunction.
SprintfBox (INFORMATION, "UseDLL", "TheExportedFunction() changed the string " +
"to: %s", svString);
// Give the user a chance to do another example.
if (AskYesNo ("Do another example?", YES) = NO) then
bDone = TRUE;
endif;
endwhile;
// Remove the .dll file from memory.
if (UnUseDLL (DLL_FILE) < 0) then
MessageBox ("UnUseDLL failed.\n\n.dll file still in memory.", SEVERE);
else
MessageBox ("UnUseDLL successful.\n\n.dll file removed from memory.",
INFORMATION);
endif;
end;
InstallShield 2016 Help LibraryMay 2017 |
Copyright Information | Flexera Software |