感谢一些前辈的分享,然后自己根据网上的资源,阅读并自己测试了自己的测试工程。
为了方便自己下一次的检索和使用,也方便他人的参考借鉴写了这篇文章。
//===========================================================================
//// File Name: Setup.rul
//
// Description: Blank setup main script file
//
// Comments: Blank setup is an empty setup project. If you want to
// create a new project via. step-by step instructions use the
// Project Assistant.
//
//===========================================================================
#define EXAMPLE_DIR "D:\\PTC\\CEAnnotation" //并没有使用,想使用的一个宏定义
// Included header files ----------------------------------------------------
#include "ifx.h"
// Note: In order to have your InstallScript function executed as a custom
// action by the Windows Installer, it must be prototyped as an
// entry-point function.
// 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); */
//安装程序的准备界面
function OnBegin()
begin
// Clear ALLUSERS if specified in the command line.
if( CMDLINE % "ALLUSERS=FALSE" ) then
ALLUSERS = FALSE;
endif;
end;
//安装的每一个对话框处理
function OnFirstUIBefore()
number nResult, nLevel, nSize, nSetupType, nUser;
string szTitle, szMsg, szOpt1, szOpt2, szLicenseFile;
string szName, szCompany, szTargetPath, szDir, szFeatures;
BOOL bLicenseAccepted;
begin
//用户点击取消,不做任何处理
if( REMOVEONLY ) then
Disable( DIALOGCACHE );
szMsg = SdLoadString( IDS_IFX_ERROR_PRODUCT_NOT_INSTALLED_UNINST );
SdSubstituteProductInfo( szMsg );
MessageBox( szMsg, SEVERE );
abort;
endif;
nSetupType = COMPLETE;
szDir = TARGETDIR;
szName = "";
szCompany = "";
bLicenseAccepted = FALSE;
// Beginning of UI Sequence
Dlg_Start:
nResult = 0;
//安装向导的欢迎界面
Dlg_SdWelcome:
szTitle = "";
szMsg = "";
//{{IS_SCRIPT_TAG(Dlg_SdWelcome)
nResult = SdWelcome( szTitle, szMsg );
//}}IS_SCRIPT_TAG(Dlg_SdWelcome)
if (nResult = BACK) goto Dlg_Start;
//许可界面
Dlg_SdLicense2:
szTitle = "";
szOpt1 = "";
szOpt2 = "";
//{{IS_SCRIPT_TAG(License_File_Path)
// 许可文件,在Behavior and Logic/ support Files/Billboards/简体中中插入的一个licence.rtf
// 该文件可以自己编写,相应安装的界面就显示相应的内容
szLicenseFile = SUPPORTDIR ^ "License.rtf";
//}}IS_SCRIPT_TAG(License_File_Path)
//{{IS_SCRIPT_TAG(Dlg_SdLicense2)
nResult = SdLicense2Rtf( szTitle, szOpt1, szOpt2, szLicenseFile, bLicenseAccepted );
//}}IS_SCRIPT_TAG(Dlg_SdLicense2)
if (nResult = BACK) then
goto Dlg_SdWelcome; //直接转到
else
bLicenseAccepted = TRUE;
endif;
/*
Dlg_SdAskDestPath2:
nSetupType = CUSTOM;
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdLicense2;
szTitle = "";
szMsg = "";
if (nSetupType = CUSTOM) then
//{{IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
nResult = SdAskDestPath2( szTitle, szMsg, szDir );
//}}IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
TARGETDIR = szDir;
endif;
//if (nResult = BACK) goto Dlg_SetupType2;
*/
//设置安装界面,帮用户指定安装目录
Dlg_SdAskDestPath2:
szTitle="系统安装目录";
szMsg="选择D:\\PTC目录,以启动程序!";
szDir="D:\\PTC";
//设置安装路径
nResult = SdAskDestPath2( szTitle, szMsg, szDir );
TARGETDIR = szDir;
if ((nResult = BACK)) goto Dlg_SdLicense2;
//拷贝所有文件
Dlg_SdStartCopy2:
szTitle = "";
szMsg = "";
//{{IS_SCRIPT_TAG(Dlg_SdStartCopy2)
nResult = SdStartCopy2( szTitle, szMsg );
//}}IS_SCRIPT_TAG(Dlg_SdStartCopy2)
if (nResult = BACK) goto Dlg_SdAskDestPath2;
// Added in 11.0 - Set appropriate StatusEx static text.
SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );
Enable(STATUSEX);
return 0;
end;
//注册表等设置
export prototype MainApp_Installed();
function MainApp_Installed()
NUMBER nSize, nType, nIcon;
STRING szKey, szName, szValue;
STRING szProgramFolder, szItemName, szCommandLine;
STRING szWorkingDir, szIconPath, szShortCutKey;
begin
// Create a sample registry key value
//
// Call RegDBSetDefaultRoot( ) to set the root key
// to the current value of the the InstallShield
// predefined constant HKEY_USER_SELECTABLE. The value
// of HKEY_USER_SELECTABLE is automatically set to
// HKEY_LOCAL_MACHINE if ALLUSERS is TRUE or
// HKEY_CURRENT_USER if ALLUSERS is FALSE.
RegDBSetDefaultRoot ( HKEY_USER_SELECTABLE_AUTO );
szKey = "SOFTWARE" ^ IFX_COMPANY_NAME ^ IFX_PRODUCT_NAME;
szName = "TestValueName2";
szValue = "TestValueData2";
nSize = -1;
RegDBSetKeyValueEx ( szKey , szName , REGDB_STRING , szValue , nSize );
end;
//---------------------------------------------------------------------------
// OnMaintUIBefore
//
// Maintenance UI Sequence - Before Move Data
//
// The OnMaintUIBefore event is called by OnShowUI when the setup is
// running in maintenance mode. By default this event displays UI that
// allows the end user to add or remove features, repair currently
// installed features or uninstall the application.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnMaintUIAfter()
STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2,szDirectory1,szDirectory2;
NUMBER bOpt1, bOpt2; begin Disable(STATUSEX);
if( REMOVEALLMODE ) then
szTitle = SdLoadString(IFX_SDFINISH_REMOVE_TITLE);
szMsg1 = SdLoadString(IFX_SDFINISH_REMOVE_MSG1);
szTitle="卸载完毕!";
szMsg1="已经完全卸载软件系统。";
szDirectory1 = TARGETDIR;
// 卸载我们装载的目录
// D:/PTC/CEAnnotation //全部的项目根目录
DeleteDir (TARGETDIR^"CEAnnotation", ALLCONTENTS);
szMsg2 ="谢谢您使用我们的软件系统。";
if ( BATCH_INSTALL ) then
SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
else
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bOpt1 , bOpt2 );
endif;
endif;
end;
Installshield工具界面: