FeatureErrorInfo Example
InstallShield 2020 ยป InstallScript Language Reference
/*--------------------------------------------------------------*\
*
* InstallShield Example Script
*
* Demonstrates the FeatureError function.
*
* This example script demonstrates a function that adds a feature
* to a script-created feature set.
*
* Comments: To run this example script, create a project (or
* insert into a project) with several features and/or
* subfeatures with components containing files.
*
\*--------------------------------------------------------------*/
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
// Include iswi.h for Windows Installer API function prototypes and constants,
// and to declare code for the OnBegin and OnEnd events.
#include "iswi.h"
// The keyword export identifies MyFunction() as an entry-point function.
// The argument it accepts must be a handle to the Installer database.
export prototype MyFunction(HWND);
prototype HandleMoveDataError(number);
// To Do: Declare global variables, define constants, and prototype user-
// defined and DLL functions here.
function MyFunction(hMSI)
STRING szTitle, szMsg;
NUMBER listID, nResult;
begin
szTitle = "List MEDIA Features";
szMsg = "MEDIA contains the following top-level features:";
// Initialize the string list.
listID = ListCreate (STRINGLIST);
// Create a list of top-level features in the specified media.
nResult = FeatureListItems (MEDIA, "", listID);
// Call the error handler function.
HandleMoveDataError (nResult);
// Display a list of top-level features.
SdShowInfoList (szTitle, szMsg, listID);
end;
function HandleMoveDataError(nResult)
STRING szErrMsg, svFeature , svComponent , svFile;
begin
svFeature = "";
svComponent = "";
svFile = "";
// In cases where FeatureListItems returns a value not equal to zero, display an
// error message.
switch (nResult)
case 0:
return 0;
default:
FeatureError (MEDIA , svFeature , svComponent , svFile , nResult);
szErrMsg = "An error occurred during the process: %d" + "\n\n" +
"Feature: " + svFeature + "\n" +
"Component: " + svComponent + "\n" +
"File: " + svFile;
SprintfBox (SEVERE, "", szErrMsg, nResult);
return nResult;
endswitch;
end;