RegDBSetAppInfo Example
InstallShield 2022 ยป 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 RegDBSetAppInfo and RegDBGetAppInfo functions.
*
* Before calling either of these functions, you must call
* InstallationInfo to set the application information.
*
\*--------------------------------------------------------------*/
#define COMPANY_NAME "Example_Company"
#define PRODUCT_NAME "Example_App"
#define PRODUCT_VERSION "5.0"
#define PRODUCT_KEY "EXAMPLE.EXE"
#define DEINSTALL_KEY "Example_DeinstKey"
#define UNINSTALL_NAME "Example_App_5.0"
#define DEFAULT_LOG_PATH "EXAMPLE"
#define TITLE "RegDBGetAppInfo"
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_RegDBSetAppInfo(HWND);
function ExFn_RegDBSetAppInfo(hMSI)
STRING szStrName, szStrValue, svStrValue, szTitle, szMsg, svLogFile;
NUMBER nvSize, nvType;
begin
// Set the root key.
RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);
// Set the name to be used with REGDB_STRING.
szStrName = "ExampleStringValue";
szStrValue = "ExampleStringSetting";
// Set up the application information prior to using RegDBSetAppInfo
// and RegDBGetAppInfo.
InstallationInfo (COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY);
DeinstallStart(DEFAULT_LOG_PATH, svLogFile, DEINSTALL_KEY, 0);
// Set value of type REGDB_STRING
if (RegDBSetAppInfo (szStrName, REGDB_STRING, szStrValue, -1) < 0) then
MessageBox ("Failed to set key and value of REGDB_STRING type.", SEVERE);
abort;
endif;
// RegDBGetAppInfo is called to return the values and compare all the setup
// parameters.
if (RegDBGetAppInfo (szStrName, nvType, svStrValue, nvSize) < 0) then
MessageBox ("Failed to get application information value.", SEVERE);
abort;
else
// Check to see if the value retrieved is the same as the value set.
if (nvType != REGDB_STRING) then
MessageBox ("Type comparison failed.", WARNING);
endif;
if (szStrValue != svStrValue) then
MessageBox ("Sub key value comparison Failed.", WARNING);
else
szMsg = "Set values: %s = %s\n\nReturn values: %s = %s";
SprintfBox (INFORMATION, TITLE, szMsg, szStrName, szStrValue,
szStrName, svStrValue);
endif;
if (nvSize != StrLength(szStrValue)) then
MessageBox ("Size Comparison failed.", WARNING);
else
szMsg = "Size in bytes entered: %d\n\nSize in bytes returned: %d";
SprintfBox (INFORMATION, TITLE, szMsg,
nvSize, StrLength(szStrValue) + 1);
endif;
endif;
end;