-
InstallShield2008脚本安装制作方法Setup
- #include "ifx.h"
- prototype CreateUninstallShortcut();
- prototype CallRegsterThirdDLL();
- prototype CallUnRegsterThirdDLL();
- prototype SetupPreCompontDLLorExe();
- function OnFirstUIBefore()
- number nResult, nLevel, nSize, nSetupType;
- string szTitle, szMsg, szOpt1, szOpt2, szLicenseFile;
- string szName, szCompany, szTargetPath, szDir, szFeatures;
- BOOL bLicenseAccepted;
- begin
-
- nSetupType = COMPLETE;
- szDir = TARGETDIR;
- szName = "";
- szCompany = "";
- bLicenseAccepted = FALSE;
-
-
- SetupPreCompontDLLorExe();
-
-
- Dlg_Start:
- nResult = 0;
- Dlg_SdWelcome:
- szTitle = "";
- szMsg = "";
-
- nResult = SdWelcome( szTitle, szMsg );
-
- if (nResult = BACK) goto Dlg_Start;
- Dlg_SdLicense2:
- szTitle = "";
- szOpt1 = "";
- szOpt2 = "";
-
- szLicenseFile = SUPPORTDIR ^ "Eula.rtf";
-
-
- nResult = SdLicense2Rtf( szTitle, szOpt1, szOpt2, szLicenseFile, bLicenseAccepted );
-
- if (nResult = BACK) then
- goto Dlg_SdWelcome;
- else
- bLicenseAccepted = TRUE;
- endif;
- Dlg_SdRegisterUser:
- szMsg = "";
- szTitle = "";
-
-
-
- if (nResult = BACK) goto Dlg_SdLicense2;
- Dlg_SetupType2:
- szTitle = "";
- szMsg = "";
- nResult = CUSTOM;
-
- nResult = SetupType2( szTitle, szMsg, "", nSetupType, 0 );
-
- 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
-
- nResult = SdAskDestPath2( szTitle, szMsg, szDir );
-
- 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
-
- nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, szFeatures, nLevel );
-
- 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 = "";
-
- nResult = SdStartCopy2( szTitle, szMsg );
-
- if (nResult = BACK) goto Dlg_ObjDialogs;
-
- SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );
- return 0;
- end;
- function SetupPreCompontDLLorExe()
- string szDotNetFx,SzLanguagePack;
- string szAERRealVersion,szAERSpNumber;
- string svNumber;
- number nvType,nvSize;
- string szOfficeLastProduct,svOfficeValue;
- string szWinInstallerExe;
- begin
-
-
-
-
-
-
-
-
-
-
- szDotNetFx = SUPPORTDIR ^ "dotnetfx.exe";
- SzLanguagePack = SUPPORTDIR ^ "langpack.exe";
-
- RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
- if (RegDBKeyExist ("SOFTWARE//Microsoft//.NETFramework//policy//v2.0" ) < 0) then
- SdShowMsg("正在安装.Net2.0运行环境,请稍候......",TRUE);
- LaunchAppAndWait(szDotNetFx,"",WAIT);
- LaunchAppAndWait(SzLanguagePack,"",WAIT);
- endif;
-
-
-
-
-
-
- szAERRealVersion="9.2";
- szAERSpNumber="3";
- nvSize=-1;
- RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
- if (RegDBGetKeyValueEx ("SOFTWARE//ESRI//ArcGIS Engine Runtime","RealVersion",nvType,svNumber,nvSize) < 0) then
- MessageBox ("未安装ArcEngine9.2+SP3补丁包,请本安装完成后再安装!", SEVERE);
- else
- if(svNumber!=szAERRealVersion) then
- MessageBox ("未安装ArcEngine9.2+SP3补丁包,请本安装完成后再安装!", SEVERE);
- else
- if(RegDBGetKeyValueEx ("SOFTWARE//ESRI//ArcGIS Engine Runtime","SPNumber",nvType,svNumber,nvSize) < 0) then
- MessageBox ("未安装ArcEngine9.2+SP3补丁包,请本安装完成后再安装!", SEVERE);
- else
- if(svNumber!=szAERSpNumber) then
- MessageBox ("未安装ArcEngine9.2+SP3补丁包,请本安装完成后再安装!", SEVERE);
- endif;
- endif;
- endif;
- endif;
-
- szOfficeLastProduct="11.0.7969.0";
- RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
- if (RegDBKeyExist ("SOFTWARE//Microsoft//Office//11.0//Common//ProductVersion" ) < 0) then
- MessageBox ("未安装Microsoft Office 2003 V11.0+SP2及以上版本,请本安装完成后再安装!", SEVERE);
- else
- if(RegDBGetKeyValueEx ("SOFTWARE//Microsoft//Office//11.0//Common//ProductVersion","LastProduct",nvType,svOfficeValue,nvSize) < 0) then
- MessageBox ("未安装Microsoft Office 2003 V11.0+SP2及以上版本,请本安装完成后再安装!", SEVERE);
- else
- if(svOfficeValue<szOfficeLastProduct) then
- MessageBox ("未安装Microsoft Office 2003 V11.0+SP2及以上版本,请本安装完成后再安装!", SEVERE);
- endif;
- endif;
- endif;
- end;
- function CallRegsterThirdDLL()
- string szDevExpress_Dll,szmicrosoft_mshtml_dll;
- begin
-
- szDevExpress_Dll = TARGETDIR ^ "//devexpress_dll//reg.bat";
-
-
- if(LaunchAppAndWait(szDevExpress_Dll,"",WAIT)<0) then
- endif;
-
-
- szmicrosoft_mshtml_dll = TARGETDIR ^ "//microsoft_mshtml_dll//reg.bat";
-
-
- if(LaunchAppAndWait(szmicrosoft_mshtml_dll,"",WAIT)<0) then
- endif;
- end;
- function CallUnRegsterThirdDLL()
- string szDevExpress_Dll,szmicrosoft_mshtml_dll;
- begin
-
- szDevExpress_Dll = TARGETDIR ^ "//devexpress_dll//unreg.bat";
-
-
- if(LaunchAppAndWait(szDevExpress_Dll,"",WAIT)<0) then
- endif;
-
-
-
-
- szmicrosoft_mshtml_dll = TARGETDIR ^ "//microsoft_mshtml_dll//unreg.bat";
-
-
-
- if(LaunchAppAndWait(szmicrosoft_mshtml_dll,"",WAIT) <0) then
- endif;
- end;
- function CreateUninstallShortcut()
- string strCmdLine;
- LIST lstPath;
- begin
-
- strCmdLine = DISK1TARGET ^ "Setup.exe";
-
- strCmdLine = UNINSTALL_STRING;
-
-
- if (SYSINFO.WIN9X.bWin9X ) then
- lstPath = ListCreate( STRINGLIST );
- StrGetTokens( lstPath, UNINSTALL_STRING, "/" );
-
- ListGetFirstString( lstPath, strCmdLine );
- LongPathToQuote( strCmdLine, TRUE );
-
- strCmdLine = strCmdLine + " /M" + PRODUCT_GUID;
- endif;
-
- AddFolderIcon(FOLDER_PROGRAMS ^ "XXXXX系统","卸载XXXXX系统V1.0",strCmdLine,"",TARGETDIR ^ "//remove.ico",0,"",REPLACE);
- end;
- function OnFirstUIAfter()
- STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
- NUMBER bvOpt1, bvOpt2;
- NUMBER bShowUpdateServiceDlg;
- begin
- ShowObjWizardPages(NEXT);
-
- szTitle = "";
- szMsg1 = "";
- szMsg2 = "";
- szOpt1 = "";
- szOpt2 = "";
- bvOpt1 = FALSE;
- bvOpt2 = FALSE;
-
-
-
- bShowUpdateServiceDlg = FALSE;
-
-
- CreateUninstallShortcut();
-
-
- CallRegsterThirdDLL();
-
-
-
- if ( BATCH_INSTALL ) then
- SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
- else
-
-
-
- if( bShowUpdateServiceDlg && ( ENABLED_ISERVICES & SERVICE_ISUPDATE ) ) then
- if( SdFinishUpdateEx( szTitle, szMsg1, szMsg2, szOpt1, szOpt2, TRUE ) ) then
-
- if( MODE != SILENTMODE ) then
- UpdateServiceCheckForUpdates( "", FALSE );
- endif;
- endif;
- else
- SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
- endif;
- endif;
-
- end;
- function OnSetTARGETDIR()
- number nId, nIgnore, nResult;
- string szId, szTARGETDIR;
- begin
-
- if( MAINTENANCE ) then
- return ISERR_SUCCESS;
- endif;
-
- TARGETDIR = "<FOLDER_APPLICATIONS>//XXXX系统";
-
- nResult = MediaGetData( MEDIA, MEDIA_FIELD_TARGETDIR, nIgnore, szTARGETDIR );
-
- if( nResult >= ISERR_SUCCESS && StrLengthChars( szTARGETDIR ) ) then
- TARGETDIR = szTARGETDIR;
- endif;
-
-
-
- if( MAINT_OPTION = MAINT_OPTION_MULTI_INSTANCE && MULTI_INSTANCE_COUNT > 0) then
-
- nId = MULTI_INSTANCE_COUNT + 1;
-
- while( ExistsDir( TARGETDIR ) = EXISTS )
-
-
- NumToStr( szId, nId );
-
-
- IFX_MULTI_INSTANCE_SUFFIX = "_" + szId;
-
-
- TARGETDIR = TARGETDIR + IFX_MULTI_INSTANCE_SUFFIX;
-
-
- nId = nId + 1;
- endwhile;
- endif;
- end;
- function OnMoved()
- begin
- end;
- function OnSetUpdateMode()
- number nIgnore, nMediaFlags, nInstalledVersion, nUpdateVersion, nResult;
- string szVersion, szIgnore, szMsg;
- begin
-
- UPDATEMODE = FALSE;
-
- if( ADDREMOVE ) then
- return ISERR_SUCCESS;
- endif;
-
- if( REMOVEONLY ) then
- return ISERR_SUCCESS;
- endif;
-
- MediaGetData( MEDIA, MEDIA_FIELD_MEDIA_FLAGS, nMediaFlags, szIgnore );
- if( ! ( nMediaFlags & MEDIA_FLAG_UPDATEMODE_SUPPORTED ) ) then
- return ISERR_SUCCESS;
- endif;
-
-
-
-
-
-
-
-
-
-
-
-
- if( !StrLengthChars( IFX_INSTALLED_VERSION ) && MAINTENANCE ) then
-
- szMsg = SdLoadString( IDS_IFX_ERROR_UPDATE_NO_INSTALLED_VERSION );
- MessageBox( szMsg, SEVERE );
- abort;
- endif;
-
- if( !StrLengthChars( IFX_PRODUCT_VERSION ) ) then
-
- szMsg = SdLoadString( IDS_IFX_ERROR_UPDATE_NO_PRODUCT_VERSION );
- MessageBox( szMsg, SEVERE );
- abort;
- endif;
-
- nResult = VerProductCompareVersions();
-
- if( nResult < ISERR_SUCCESS ) then
- szMsg = SdLoadString( IDS_IFX_ERROR_UPDATE_VERSION_COMPARE_FAILURE );
- MessageBox( szMsg, SEVERE );
- abort;
- endif;
-
- UPDATEMODE = ( nMediaFlags & MEDIA_FLAG_FORMAT_DIFFERENTIAL || ( MAINTENANCE && ( nResult != VERSION_COMPARE_RESULT_SAME ) ) );
- end;
- function OnCheckMediaPassword()
- string szResult, szMsg;
- BOOL bValidated;
- begin
-
- if( !SHOW_PASSWORD_DIALOG ) then;
- return ISERR_SUCCESS;
- endif;
-
- LogReadCustomString( MEDIA_PASSWORD_KEY, szResult );
- if( FeatureValidate( MEDIA, "", szResult ) == 0 ) then
- return ISERR_SUCCESS;
- endif;
-
- Disable( BACKBUTTON );
-
- bValidated = FALSE;
-
- while( !bValidated )
-
- if( EnterPassword( "", "", szResult ) < ISERR_SUCCESS ) then
- abort;
- endif;
-
- if( FeatureValidate( MEDIA, "", szResult ) == 0 ) then
-
-
- LogWriteCustomString( MEDIA_PASSWORD_KEY, szResult );
- bValidated = TRUE;
- else
- szMsg = SdLoadString( IDS_IFX_ERROR_INVALID_MEDIA_PASSWORD );
- MessageBox( szMsg, INFORMATION );
- endif;
- endwhile;
-
- Enable( BACKBUTTON );
- end;
- function OnEnd()
- begin
- end;
- function OnUninstall()
- string szIgnore, szMsg;
- number nResult;
- BOOL bOpt1, bOpt2;
- begin
-
- Disable( DIALOGCACHE );
-
-
- if( MessageBox( SdLoadString( IFX_MAINTUI_MSG ), MB_YESNO ) != IDYES ) then
- abort;
- endif;
-
-
- CallUnRegsterThirdDLL();
-
- FeatureRemoveAllInMediaAndLog();
-
- if( REMOVEALLMODE ) then
- Disable( CANCELBUTTON );
- endif;
-
-
-
- SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REMOVEALL ) );
-
- SetStatusWindow( 0, "" );
- Enable( STATUSEX );
- StatusUpdate( ON, 100 );
-
- nResult = FeatureTransferData( MEDIA );
-
- if( nResult < ISERR_SUCCESS ) then
- OnComponentError();
- abort;
- endif;
-
- Disable( STATUSEX );
-
- if ( BATCH_INSTALL ) then
- SdFinishReboot( SdLoadString(IFX_SDFINISH_REMOVE_TITLE), SdLoadString(IFX_SDFINISH_REMOVE_MSG2), SYS_BOOTMACHINE, "", 0 );
- else
- SdFinish( SdLoadString(IFX_SDFINISH_REMOVE_TITLE), SdLoadString(IFX_SDFINISH_REMOVE_MSG1), "", "" , "", bOpt1 , bOpt2 );
- endif;
- end;
-
-
相关阅读:
括号匹配性检测C语言实现
预处理命令--宏定义
*运算和&运算
retain, copy, assign以及autorelease
自定义 一个单例
多米音乐笔试题
UI-自定义视图、视图控制器
Foundation框架—集合
Foundation框架—字符串
Foundation框架—结构体
-
原文地址:https://www.cnblogs.com/Alex80/p/4331514.html
Copyright © 2020-2023
润新知