大家可以把所有事件都点出来然后单步追踪就行了,我的经验是一般是从OnShowUI第一次显示UI界面开始,很容易就找到大家想处理的事件,另贴几个我发现的事件,这些事件描述不是很准确大家不要当真哦.
在加一些文件注册 服务开启 动作.
#include "ifx.h"
//这是一个自定义函数
prototype MsgBox(STRING);//声名函数原型
function MsgBox(msg)
begin
//return MessageBox (msg,SEVERE);
return MessageBox (msg,MB_YESNO);
end;
#include "ifx.h"
//---------------------------------------------------------------------------
// OnFirstUIBefore
//
//---------------------------------------------------------------------------
function OnFirstUIBefore()
number nResult, nLevel, nSize, nSetupType;
string szTitle, szMsg, szOpt1, szOpt2, szLicenseFile,szKeyRoot;
string szName, szCompany, szTargetPath, szDir, szFeatures;
BOOL bLicenseAccepted;
string szExePath,szCmdPath;
NUMERIC szServiceState ;
begin
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)
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_SdRegisterUser:
szMsg = "";
szTitle = "";
//{{IS_SCRIPT_TAG(Dlg_SdRegisterUser)
nResult = SdRegisterUser( szTitle, szMsg, szName, szCompany );
//}}IS_SCRIPT_TAG(Dlg_SdRegisterUser)
if (nResult = BACK) goto Dlg_SdLicense2;
Dlg_SetupType2:
szTitle = "";
szMsg = "";
nResult = CUSTOM;
//{{IS_SCRIPT_TAG(Dlg_SetupType2)
nResult = SetupType2( szTitle, szMsg, "", nSetupType, 0 );
//}}IS_SCRIPT_TAG(Dlg_SetupType2)
if (nResult = BACK) then
goto Dlg_SdRegisterUser;
else
nSetupType = nResult;
if (nSetupType != CUSTOM) then
szTargetPath = TARGETDIR;
nSize = 0;
FeatureCompareSizeRequired( MEDIA, szTargetPath, nSize );
if (nSize != 0) then
MessageBox( szSdStr_NotEnoughSpace, WARNING );
goto Dlg_SetupType2;
endif;
endif;
endif;
Dlg_SdAskDestPath2:
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType2;
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_SdFeatureTree:
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdAskDestPath2;
szTitle = "";
szMsg = "";
szFeatures = "";
nLevel = 2;
if (nSetupType = CUSTOM) then
//{{IS_SCRIPT_TAG(Dlg_SdFeatureTree)
nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, szFeatures, nLevel );
//}}IS_SCRIPT_TAG(Dlg_SdFeatureTree)
if (nResult = BACK) goto Dlg_SdAskDestPath2;
endif;
Dlg_SQLServer:
nResult = OnSQLServerInitialize( nResult );
if( nResult = BACK ) goto Dlg_SdFeatureTree;
Dlg_ObjDialogs:
nResult = ShowObjWizardPages( nResult );
if (nResult = BACK) goto Dlg_SQLServer;
Dlg_SdStartCopy2:
szTitle = "";
szMsg = "";
//显示各种路径
MessageBox("TARGETDIR=" + TARGETDIR + "/n"
+"SUPPORTDIR=" + SUPPORTDIR + "/n"
+"WINSYSDIR=" + WINSYSDIR + "/n"
+"DISK1TARGET=" + DISK1TARGET + "/n"
+"<FOLDER_APPLICATIONS>=" + FOLDER_APPLICATIONS + "/n"
+"<IFX_COMPANY_NAME>=" + IFX_COMPANY_NAME + "/n"
+"<IFX_PRODUCT_NAME>=" + IFX_PRODUCT_NAME + "/n"
+"szOpt2=" + szOpt2 + "/n"
+"szLicenseFile=" + szLicenseFile + "/n"
+"szTargetPath=" + szTargetPath + "/n"
+"szDir=" + szDir + "/n"
+"szFeatures=" + szFeatures + "/n"
+"szOpt1=" + szOpt1 + "/n",MB_YESNO);
//开始安装其他的程序
szExePath = SUPPORTDIR ^ "test.exe"; //这个是放入缓存文件夹里面执行,执行完后自动删除
//添加缓存文件夹步骤
//1.选择Support Files /Billboards ->Language IndePendent -> INsert File
//安装其他程序
//只能判断程序执行没执行 不能判断执行安装成功,需要通过读取注册表来判断
//if LaunchAppAndWait (szExePath, "", WAIT) < 0 then
// MessageBox("不能安装该程序,本次安装失败!",SEVERE);
// abort;
//endif;
//执行Bat文件
//szExePath = SUPPORTDIR ^ "test.bat";
//if LaunchAppAndWait (szExePath, "", WAIT) < 0 then
// MessageBox("bat程序执行失败",SEVERE);
// abort;
//endif;
//注意了 执行这些.exe .bat 文件一定要放到SUPPORTDIR 文件夹去,直接D:/test.bat不能直接执行成的
//当然下面的cmd.exe 系统命令除外,我估计是他内至支持的(估计的!)
//执行CMd命令 /c 注意这个/ 不是/记住
// szExePath = WINSYSDIR^ "cmd.exe";
// if LaunchAppAndWait (szExePath, "/c del c://01.txt", WAIT) < 0 then
// MessageBox("CMD执行失败",SEVERE);
// abort;
//endif;
//关于注册 在我们使用InstallShield导入文件时,可以设置selt-register 他就会自动注册与卸载了.
//执行RegSvr32注册组件命令
//szExePath = "/s C://Example//原始文件//jmail.dll"; //注意/s 参数要放在参数命令里
// if LaunchAppAndWait (WINSYSDIR ^ "Regsvr32", szExePath , WAIT) < 0 then
// MessageBox("注册组件执行失败",SEVERE);
// abort;
//endif;
//取消注册
//szExePath = "/s /u C://Example//原始文件//jmail.dll"; // /u 卸载
// if LaunchAppAndWait (WINSYSDIR ^ "Regsvr32", szExePath , WAIT) < 0 then
// MessageBox("取消注册组件执行失败",SEVERE);
// abort;
//endif;
//关闭服务
//szExePath = WINSYSDIR^ "NET";
//if LaunchAppAndWait (szExePath, "STOP MSSQLSERVER", WAIT) < 0 then
// MessageBox("关闭服务失败",SEVERE);
// abort;
// endif;
//开启服务
//szExePath = WINSYSDIR^ "NET";
//if LaunchAppAndWait (szExePath, "START MSSQLSERVER", WAIT) < 0 then
// MessageBox("开启服务失败",SEVERE);
// abort;
//endif;
//判断服务是否开启
szServiceState = SERVICE_STOP_PENDING; //这里主要是定义数据类型,这个很重要 否则出错.
if ServiceGetServiceState("MSSQLSERVER", szServiceState)< ISERR_SUCCESS then
MessageBox("MSSQLSERVER服务关闭",SEVERE);
else
MessageBox("MSSQLSERVER服务开启",SEVERE);
endif;
// ServiceAddService 添加服务 ServiceRemoveService 删除服务
//ServiceExistsService 判断服务是否存在 ServiceGetServiceState 检查服务是否启动
//if MessageBox("是否关闭服务!",MB_YESNO) = IDYES then
// ServiceStopService("MSSQLSERVER");
//endif;
//if MessageBox("是否开启服务!",MB_YESNO) = IDYES then
// ServiceStartService("MSSQLSERVER","");
//endif;
if MessageBox("是否退出本次安装!",MB_YESNO) = IDYES then
abort;
endif;
//{{IS_SCRIPT_TAG(Dlg_SdStartCopy2)
nResult = SdStartCopy2( szTitle, szMsg );
//}}IS_SCRIPT_TAG(Dlg_SdStartCopy2)
if (nResult = BACK) goto Dlg_ObjDialogs;
//这里开始写注册表
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); //设置注册表函数默认值
//szKeyRoot = "SOFTWARE//ISsample" ; //需创建多个子项时要一个一个创建否则卸载不了
//RegDBCreateKeyEx (szKeyRoot , "" ); //了用""代替类
//设置键值 size = -1 InstallShield自动设置大小
//RegDBSetKeyValueEx(szKeyRoot,"config_string",REGDB_STRING,"Hello",-1);
//RegDBSetKeyValueEx(szKeyRoot,"config_numer",REGDB_NUMBER,"1",-1);
//在本身创建的目录下写注册表
szKeyRoot = "SOFTWARE"^IFX_COMPANY_NAME^IFX_PRODUCT_NAME ;
RegDBSetKeyValueEx(szKeyRoot,"Path",REGDB_STRING,TARGETDIR,-1);
RegDBSetKeyValueEx(szKeyRoot,"config",REGDB_NUMBER,"1",-1);
// Added in 11.0 - Set appropriate StatusEx static text.
SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );
return 0;
end;
//---------------------------------------------------------------------------
// OnMaintUIBefore
// 卸载向导页
//---------------------------------------------------------------------------
function OnMaintUIBefore()
number nResult, nType, nMediaFlags;
string szTitle, szMsg, szIgnore;
string szKeyRoot,szPath ,szConfigStr;
int szConfig;
NUMBER nType1,nType2,nvSize; //提取注册表时,一定要把他转换成这种数据类型,否则出错
begin
//显示注册表值
nType1 = REGDB_STRING;
nType2 = REGDB_NUMBER;
nvSize = -1;
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
szKeyRoot = "SOFTWARE"^IFX_COMPANY_NAME^IFX_PRODUCT_NAME;
//RegDBSetKeyValueEx (szKeyRoot, "Path", nType1, "Hello",nvSize);//看能否取到值
RegDBGetKeyValueEx (szKeyRoot, "Path", nType1, szPath,nvSize);
//RegDBGetKeyValueEx (szKeyRoot, "config",nType2, szConfig,nvSize);
MessageBox("路径:" + szKeyRoot + "注册表值:"+ szPath ,MB_YESNO);
// nType defaults to MODIFY.
nType = MODIFY; //可修改这个默认值
//Initialize SQL
OnSQLServerInitializeMaint();
// Beginning of UI Sequence
Dlg_Start:
// Added in Version 9.5 - Support for REMOVEONLY option.
if( !REMOVEONLY ) then
// In standard mode show maintenance dialog
Disable( BACKBUTTON );
nType = SdWelcomeMaint( szTitle, szMsg, nType );
Enable( BACKBUTTON );
nResult = NEXT;
else
// Hide the initial progress dialog as otherwise the user can
// click on it, and hide the MessageBox.
Disable( DIALOGCACHE );
// In RemoveOnly mode, set to remove.
nType = REMOVEALL;
endif;
// Show Uninstall Confirmation Dialog
if ( nType = REMOVEALL ) then //删除事件
nResult = MessageBox( SdLoadString( IFX_MAINTUI_MSG ), MB_YESNO );
if (nResult != IDYES ) then
if( REMOVEONLY ) then
// In REMOVEONLY mode, abort the setup.
abort;
else
// In non-REMOVEONLY mode, redisplay the previous dialog.
goto Dlg_Start;
endif;
endif;
endif;
Dlg_SdFeatureTree:
if ( nType = MODIFY ) then
szTitle = "";
szMsg = SdLoadString( SD_STR_COMPONENT_MAINT_MSG );
nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, "", -1 );
if ( nResult = BACK ) goto Dlg_Start;
endif;
Dlg_ObjDialogs:
nResult = ShowObjWizardPages( nResult );
if ( ( nResult = BACK ) && ( nType != MODIFY ) ) goto Dlg_Start;
if ( ( nResult = BACK ) && ( nType = MODIFY ) ) goto Dlg_SdFeatureTree;
switch(nType)
case REMOVEALL: //卸载调用 (有卸载有做的动作都可以放到这里来)
// Ensure that all previously installed features are removed
// for media that supports updating.
MediaGetData( MEDIA, MEDIA_FIELD_MEDIA_FLAGS, nMediaFlags, szIgnore );
if( nMediaFlags & MEDIA_FLAG_UPDATEMODE_SUPPORTED ) then
FeatureRemoveAllInMediaAndLog();
else
FeatureRemoveAllInMedia();
endif;
// Added in 11.0 - Set appropriate StatusEx static text.
SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REMOVEALL ) );
case REPAIR: //修复
// Changed for DevStudio 9, Disk1 files are now always updated when installed
// so when running from ADDREMOVE we need to prevent these files from being
// updated since this will result in files being updated that are locked by the setup.
// Updating these files when running from ADDREMOVE should not be needed since updates
// are not run directly from Add/Remove.
if( ADDREMOVE ) then
// Reinstall all previously installed features, except
// disk1 features.
FeatureUpdate( "" );
else
// Reinstall all previously installed features.
FeatureReinstall();
endif;
// Added in 11.0 - Set appropriate StatusEx static text.
SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REPAIR ) );
case MODIFY: //修改事件
// Added in 11.0 - Set appropriate StatusEx static text.
SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_MODIFY ) );
endswitch;
end;
//---------------------------------------------------------------------------
// OnFirstUIAfter
// 安装完成后,点完成前发生的事件
//
//---------------------------------------------------------------------------
function OnFirstUIAfter()
STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
NUMBER bvOpt1, bvOpt2;
NUMBER bShowUpdateServiceDlg;
begin
//MessageBox("开始了OnFirStUIAfter!",MB_YESNO ) ;
ShowObjWizardPages(NEXT);
szTitle = "";
szMsg1 = "";
szMsg2 = "";
szOpt1 = "";
szOpt2 = "";
bvOpt1 = FALSE;
bvOpt2 = FALSE;
// Set this to true if you have the update service enabled, and if you want to check for updates.
// Note: the ISUS Starter Edition does not support checking for updates programatically. So,
// only set this to true if you have at least the ISUS Professional Edition.
bShowUpdateServiceDlg = FALSE;
//{{IS_SCRIPT_TAG(Dlg_SdDinishEx)
if ( BATCH_INSTALL ) then
SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
else
// If the update service is enabled, show finish dialog that includes
// update check option.
if( bShowUpdateServiceDlg && ( ENABLED_ISERVICES & SERVICE_ISUPDATE ) ) then
if( SdFinishUpdateEx( szTitle, szMsg1, szMsg2, szOpt1, szOpt2, TRUE ) ) then
// Don't check for updates in silent mode.
if( MODE != SILENTMODE ) then
UpdateServiceCheckForUpdates( "", FALSE );
endif;
endif;
else
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
endif;
endif;
//}}IS_SCRIPT_TAG(Dlg_SdDinishEx)
end;
//---------------------------------------------------------------------------
// OnAbort
//取消按钮退出,最后点完成发生事件
//---------------------------------------------------------------------------
function OnAbort()
begin
//MessageBox("发生OnAbort事件!", MB_YESNO ) ;
end;
//---------------------------------------------------------------------------
// OnUpdateUIAfter
//
// Update Mode UI Sequence - After Move Data
//
// The OnUpdateUIAfter event called by OnShowUI after the file transfer
// of the setup when the setup is running in update mode. By default
// this event displays UI that informs the end user that the maintenance setup
// has been completed successfully.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnUpdateUIAfter()
string szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
BOOL bOpt1, bOpt2;
begin
MessageBox("OnUninstall", MB_YESNO ) ;
ShowObjWizardPages(NEXT);
szTitle = SdLoadString(IDS_IFX_SDFINISH_UPDATE_TITLE);
szMsg1 = SdLoadString(IDS_IFX_SDFINISH_UPDATE_MSG1);
szMsg2 = "";
szOpt1 = "";
szOpt2 = "";
bOpt1 = FALSE;
bOpt2 = FALSE;
if ( BATCH_INSTALL ) then
SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
else
SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bOpt1 , bOpt2 );
endif;
end;
//---------------------------------------------------------------------------
// OnShowUI
//在第一次弹出向导页发生
//---------------------------------------------------------------------------
function OnShowUI()
BOOL bMaintenanceMode, bUpdateMode;
string szIgnore, szTitle;
begin
//MessageBox("OnShowUI", MB_YESNO ) ;
// Enable dialog caching
Enable( DIALOGCACHE );
// Determine what events to show.
bUpdateMode = FALSE;
bMaintenanceMode = FALSE;
// Remove this to disabled update mode.
if( UPDATEMODE ) then
bUpdateMode = TRUE;
endif;
// Remove this to disable maintenance mode.
if ( MAINTENANCE ) then
bMaintenanceMode = TRUE;
endif;
// Show appropriate UI
// TODO: Enable if you want to enable background etc.
//if ( LoadStringFromStringTable( "TITLE_MAIN", szTitle ) < ISERR_SUCCESS ) then // Load the title string.
// szTitle = IFX_SETUP_TITLE;
//endif;
//SetTitle( szTitle, 24, WHITE );
//Enable( FULLWINDOWMODE );
//Enable( BACKGROUND );
//SetColor( BACKGROUND, RGB( 0, 128, 128 ) );
if( bUpdateMode ) then
OnUpdateUIBefore();
else
if ( bMaintenanceMode ) then
OnMaintUIBefore();
else
OnFirstUIBefore();
endif;
endif;
// Move Data
OnMoveData();
if( bUpdateMode ) then
OnUpdateUIAfter();
else
if ( bMaintenanceMode ) then
OnMaintUIAfter();
else
OnFirstUIAfter();
endif;
endif;
// Disable dialog caching
Disable(DIALOGCACHE);
end;
//下面介绍一些长用常量:
BATCH_INSTALL 指示当传输文件采用LOCKEDFILE或SHAREDFILE时是否锁定文件
CMDLINE Setup.exe传递的命令行参数
COMMONFILES Common files全路径如“c:/program file/common files”
ERRORFILENAME
FOLDER_DESKTOP Windows 95 或Windows NT 4.0桌面folder的路径
FOLDER_PROGRAMS Windows 95 或Windows NT 4.0 开始菜单中 开始/程序 的folder
FOLDER_STARTMENU Windows 95 或Windows NT 4.0 开始菜单中 开始 的folder
FOLDER_STARTUP Windows 95 or Windows NT 4.0 开始菜单中 启动 的folder
INFOFILENAME InstallShield创建的备份文件全文件名
ISRES _isres.dll全文件名
ISUSER _isuser.dll全文件名
ISVERSION 版本
MEDIA 当前Media库名
MODE 指示程序运行于normal还是silent模式
PROGRAMFILES Windows 95 or Windows NT 4.0 “Program files” folder
SELECTED_LANGUAGE 安装选择的语言号
SRCDIR 安装源目录的全路径
SRCDISK 安装源目录的盘符
SUPPORTDIR 临时文件路径
TARGETDIR 安装目的目录的全路径
TARGETDISK 安装目的目录的盘符
UNINST unInstallShield程序用的反安装文件全文件名
WINDIR Windows的全路径(c:/windows)
WINDISK Windows位于的盘符
WINSYSDIR Windows/system的全路径(c:/windows/system32)
WINSYSDISK Windows/system位于的盘符
FOLDER_LOCAL_APPDATA //用户系统目录
DISK1TARGET // 安装文件所在路径
FOLDER_APPLICATIONS
IFX_COMPANY_NAME //发布者名
IFX_PRODUCT_NAME //程序名
IFX_PRODUCT_VERSION //版本号
(你也可以在帮助文件中搜索 IFX 就会显示出保存输入值的常量)