正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!
您需要 登录 才可以下载或查看,没有账号?立即注册
x
1、Setup.Rul
- //===========================================================================
- //
- // 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.
- //
- //描述:空白设置主脚本文件
- // 评论:空白的设置是一个空的安装项目。如果你想通过创建一个新的项目。分步说明使用项目助理
- //===========================================================================
-
- // Included header files ----------------------------------------------------
- #include "ifx.h"
- BOOL bWinLogin;
- string szServer, szUser, szPassword;
- //---------------------------------------------------------------
- prototype WriteDBInfo(STRING);
- function WriteDBInfo(dbConnection)
- string svResult;
- number nvFileHandle;
- begin
-
- //写获取连接数据库文件
- OpenFileMode(FILE_MODE_APPEND);
- if (FindFile(ProgramFilesFolder+"//"+@COMPANY_NAME+"//示例数据库","DBConnection.txt", svResult) < 0) then //没有,需要create一个
- CreateFile(nvFileHandle,ProgramFilesFolder+"//"+@COMPANY_NAME+"//示例数据库","DBConnection.txt");
- else
- OpenFile (nvFileHandle ,ProgramFilesFolder+"//"+@COMPANY_NAME+"//示例数据库","DBConnection.txt");
- endif;
- WriteLine( nvFileHandle,dbConnection);
- CloseFile(nvFileHandle);
- end ;
- /////////////////////////////////////////////////////////////////////////////////////////////////
- prototype DetachDB();
- function number DetachDB()
- STRING szCmdLine,szWaitTxt;
- string svResult,svLine;
- number nvFileHandle;
- begin
- OpenFileMode(FILE_MODE_APPEND);
- szWaitTxt=" 正在分离安装网站使用的数据库……";
- SdShowMsg (szWaitTxt, TRUE);
- Delay(2);
- //szCmdLine = "/E /S "+svSQLsvr+" /Q /"EXEC sp_detach_db @dbname = N'YCSCMDB'";
- //读取连接字符串
- if (FindFile(ProgramFilesFolder+"//"+@COMPANY_NAME+"//示例数据库","DBConnection.txt", svResult) <0) then
- MessageBox ("数据库配置文件丢失,请手动分离或删除网站使用的数据库!",SEVERE);
- else
- OpenFile ( nvFileHandle ,ProgramFilesFolder+"//"+@COMPANY_NAME+"//示例数据库","DBConnection.txt");
- ab:
- if(GetLine( nvFileHandle,svLine)<0) then
- CloseFile(nvFileHandle);
- else
- szCmdLine =svLine+" /Q /"EXEC sp_detach_db @dbname = N'YCSCMDB'/"";
- //szCmdLine = "/U "+svSQLusr+" /P "+svSQLpwd+" /S "+svSQLsvr+" /Q /"EXEC sp_attach_db @dbname = N'dlbj',@filename1 = N'"+TARGETDIR ^"dlbj_web.MDF',@filename2 = N'"+TARGETDIR ^"dlbmydb_log.LDF'/"";
- LaunchAppAndWait("osql.exe", szCmdLine,WAIT);
- if(LaunchAppAndWait("osql.exe", szCmdLine,WAIT)<0) then
- MessageBox ("数据库分离失败!请手动分离或删除网站使用的数据库!",SEVERE);
- else
- goto ab;
- endif;
- endif;
- SdShowMsg (szWaitTxt, FALSE);
- endif;
-
- //szWaitTxt=" 正在优化系统数据库……";
- //SdShowMsg (szWaitTxt, TRUE);
- //Delay(2);
- //szCmdLine = "/U "+svSQLusr+" /P "+svSQLpwd+" /S "+svSQLsvr+" /Q /"use dlbj ; exec sp_updatestats/"";
- // if (LaunchAppAndWait("osql.exe", szCmdLine,WAIT) < 0) then
- // MessageBox ("数据库优化失败!您可以在 sql查询分析器中执行 use dlbj ; exec sp_updatestats 完成!",SEVERE);
- // endif;
- // SdShowMsg (szWaitTxt, FALSE);
-
- return 0;
-
- end;
- //---------------------------------------------------------------------------
-
- // 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); */
- //注意:为了让您的InstallScript中作为一个自定义的执行
- //由Windows Installer的行动,它必须作为一个原型 入口点函数。
-
- //关键字出口标识调用MyFunction()作为入口点函数。
- //它接受的参数必须是一个句柄安装程序数据库。
-
- //*出口原型调用MyFunction(HWND); * /
-
- //-----------------------------------------------------------------------
- prototype CheckIIS(); //检测是否安装了iis
- //--------------------------------------------------------
- //检测是否安装了IIS
- function CheckIIS()
- NUMBER nvType, nvSize;
- STRING svvalue;
- begin
- RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
- if (RegDBKeyExist ("System//CurrentControlSet//Services//IISADMIN" ) = 1) then
- return (1);
- else
- return (0);
- endif;
- end;
- //-----------------------------------------------------------
-
- //---------------------------------------------------------------------------
- // OnFirstUIBefore
- //
- // The OnFirstUIBefore event is called by the framework when the setup is
- // running in first install mode. By default this event displays UI allowing
- // the end user to specify installation parameters.
- //该事件被称为OnFirstUIBefore由框架时,安装程序
- //运行在第一次安装模式。允许默认情况下此事件显示界面
- //最终用户指定安装参数。
- //---------------------------------------------------------------------------
- function OnFirstUIBefore()
- NUMBER nResult, nSetupType, nvSize, nUser;
- STRING szTitle, szMsg, szQuestion, svName, svCompany, szFile;
- STRING szLicenseFile;
-
- LIST list, listStartCopy;
- BOOL bCustom;
- STRING szBmpPath, szAppPath,svResult,svLine,svSubStr,szIp;//自定义
- number nvFileHandle,nvIp;
- string szOpt1, szOpt2;
- BOOL bLicenseAccepted;
- begin
- // TO DO: if you want to enable background, window title, and caption bar title
- // SetTitle( @PRODUCT_NAME, 24, WHITE );
- // SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION );
- // Enable( FULLWINDOWMODE );
- // Enable( BACKGROUND );
- // SetColor(BACKGROUND,RGB (0, 128, 128));
-
- SHELL_OBJECT_FOLDER = @PRODUCT_NAME;
-
- nSetupType = TYPICAL;
- //-----------------------------------------------------------------------
- //设置背景图片
- SetTitle("欢迎您使用银河卡电子产品", 24, WHITE);
- SetTitle( "安装“网上阅卷系统”",0,BACKGROUNDCAPTION);
- Enable(FULLWINDOWMODE);
- Enable(BACKGROUND );
- // PlaceBitmap (SUPPORTDIR^"BackGround.bmp",0,0,0,UPPER_LEFT); //左上角显示图片
- // PlaceBitmap (SUPPORTDIR^"BackGround.bmp",0,0,0,FULLSCREENSIZE); //全屏显示图片
- //PlaceWindow ( BILLBOARD , 200 , 40 , UPPER_LEFT ); //平铺logo
- //SetDisplayEffect(EFF_FADE);//设置显示效果
- // PlaceWindow ( BILLBOARD , 200 , 40 , UPPER_LEFT );
- //PlaceWindow(BACKGROUND,10,10,UPPER_LEFT); //背景窗口的位置为左上方开始10,10
- SetColor(BACKGROUND,RGB (0, 128, 128));
- //----------------------------------------------------------------
- //----------------------------------------------------------------
- szBmpPath=SUPPORTDIR+"//left.bmp;1;0,0,0"; //图片有白色的背景,所以设置白色为透明色 “位图文件名;透明标志;<未用>;<未用>;透明色”标准位图为57×53
- //SizeWindow (METAFILE,50, 50);
- DialogSetInfo (DLG_INFO_ALTIMAGE, szBmpPath,TRUE); // 设置左边的logo图片
- //------------------------------------------------------------------
- //------------------------------------------------------------------
-
- SdShowMsg( "安装程序正在检测系统必备组件...... ",TRUE);
- Delay(2);
- SdShowMsg ("",FALSE);
- //---------------------------------------------------------------------
- WriteIp:
- //写获取ip地址文件
- OpenFileMode(FILE_MODE_APPEND);
- if (FindFile(SUPPORTDIR,"ipconfig.bat", svResult) < 0) then //没有,需要create一个
- CreateFile(nvFileHandle,SUPPORTDIR,"ipconfig.bat");
- else
- OpenFile ( nvFileHandle ,SUPPORTDIR,"ipconfig.bat");
- //LaunchAppAndWait("","net stop w3svc"+"/S",WAIT);
- endif;
- WriteLine( nvFileHandle,"ipconfig /all >> /""+SUPPORTDIR+"/ipconfig.txt/"");
- CloseFile(nvFileHandle);
- LaunchAppAndWait("",SUPPORTDIR^"ipconfig.bat",WAIT);
- //----------------------------------------------------------------------------------
- //读取ip地址
- if (FindFile( SUPPORTDIR,"ipconfig.txt", svResult) < 0) then //没有,需要create一个
- goto WriteIp;
- else
- OpenFile ( nvFileHandle ,SUPPORTDIR,"ipconfig.txt");
- endif;
- ab:
- if(GetLine( nvFileHandle,svLine)<0) then
- CloseFile(nvFileHandle);
- else
- nvIp=StrFind(svLine,"Ethernet adapter 本地连接:");
- if(nvIp>-1)then
- cd:
- if(GetLine( nvFileHandle,svLine)<0) then
- CloseFile(nvFileHandle);
- else
- nvIp=StrFind (svLine,"IP Address");
- if(nvIp>-1)then
- StrSub (svSubStr, svLine,nvIp+StrLength("IP Address. . . . . . . . . . . . : "), StrLength (svLine)-nvIp+StrLength("IP Address. . . . . . . . . . . . : "));
- szIp=svSubStr;
- else
- goto cd;
- endif;
- endif;
- else
- goto ab;
- endif;
- endif;
- //--------------------------------------------------------------------------------------
- SetIIS:
- //安装iis
- //szProgram = "rundll32.exe";
- //szCmdLine = "setupapi.dll,InstallHinfSection Modem1 132 " + WINDIR + "driver139//oxser.inf";
- if CheckIIS() then
- goto SetDotNet;
- else
- SprintfBox(MB_OK,"IIS安装","您还未安装IIS,请安装!");
- if(LaunchAppAndWait("rundll32.exe", "shell32.dll,Control_RunDLL appwiz.cpl,,2", WAIT)<0)then
- SprintfBox(MB_OK,"IIS安装","IIS安装时发生意外,请重新安装!");
- else
- goto SetIIS;
- endif;
- endif;
- //---------------------------------------------------------------------------
- SetDotNet:
- //判断是否安装了.netframework
- RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
- if ( RegDBKeyExist ("SOFTWARE//Microsoft//.NETFramework//policy//v2.0" ) < 0) then
- SprintfBox(MB_OK,".NET安装","尚未安装.net framework 2.0 !/n请点击“确定”以继续安装!");
- if( LaunchAppAndWait( SUPPORTDIR ^ "dotnetfx.exe" , "/q:a/l" ,WAIT) < 0) then
- SprintfBox(MB_OK,".NET安装","安装.net框架时发生意外,请重新安装!");
- else
- SprintfBox(MB_OK,".NET安装",".NET FrameWork 2.0已安装!");
- endif;
- endif;
- //----------------------------------------------------------------------
- SetSqlServer:
- //判断是否安装了SQL Server
- RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
- if ( RegDBSetKeyValueEx ("SOFTWARE//Microsoft//Microsoft SQL Server//80//MSSQLLicenseInfo//MSSQL8.00//DisplayName","DisplayName",REGDB_STRING,"SQL Server 2000",-1 ) < 0) then
- SprintfBox(MB_OK,"SQL Server 2000 安装","尚未安装SQL Server 2000 !/n请点击“确定”以继续安装!");
- if( LaunchAppAndWait( SUPPORTDIR ^ "SQL 2000 Enterprise//AUTORUN.EXE.exe" , "/q:a/l" ,WAIT) < 0) then
- SprintfBox(MB_OK,"SQL Server 2000 安装","安装SQL Server 2000 时发生意外,请重新安装!");
- else
- SprintfBox(MB_OK,"SQL Server 2000 安装","SQL Server 2000 已安装!");
- endif;
- endif;
- //------------------------------------------------------------------
-
- Dlg_SdWelcome: //欢迎 对话框
- szTitle = "欢迎使用YHK_GF安装软件";
- szMsg = "YHK_GF安装软件将在您的计算机中安装/b/n/b/n“网上阅卷系统”,/b/n/b/n若要继续,请单击“下一步”。";
- nResult = SdWelcome(szTitle, szMsg);
- if (nResult = BACK) goto Dlg_SdWelcome;
-
- Dlg_SdLicense2: //软件许可协议
- szTitle ="欢迎您/b/n请仔细阅读用户协议,本协议具有法律效力!!";
- szOpt1 = "同意(&A)";
- szOpt2 = "不同意(&D)";
- //{{IS_SCRIPT_TAG(License_File_Path)
- szLicenseFile = SUPPORTDIR ^ "用户使用协议.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_SdCustomerInformation:
- //用户信息对话框
- szMsg = "请您填写用户信息卡";
- szTitle = "欢迎您/b/n使用YHK安装系统";
- svName = "";
- svCompany = "";
- nResult = SdCustomerInformation(szTitle, svName, svCompany, nUser);
- if (nResult = BACK) goto Dlg_SdWelcome;
-
-
- Dlg_SetupType: //安装类型对话框
- szTitle = "安装类型/b/n请选择安装类型";
- szMsg = "请选择安装";
- nResult = SetupType(szTitle, szMsg, "", nSetupType, 0);
- if (nResult = BACK) then
- goto Dlg_SdCustomerInformation;
- else
- nSetupType = nResult;
- if (nSetupType != CUSTOM) then
- nvSize = 0;
- FeatureCompareSizeRequired(MEDIA, INSTALLDIR, nvSize);
- if (nvSize != 0) then
- MessageBox(szSdStr_NotEnoughSpace, WARNING);
- goto Dlg_SetupType;
- endif;
- bCustom = FALSE;
- goto Dlg_SQL;
- else
- bCustom = TRUE;
- endif;
- endif;
-
- Dlg_SdAskDestPath:
- szTitle="";
- szMsg="";
- nResult = SdAskDestPath(szTitle, szMsg, INSTALLDIR, 0);
- if (nResult = BACK) goto Dlg_SetupType;
-
- Dlg_SdFeatureTree:
- szTitle = "";
- szMsg = "";
- if (nSetupType = CUSTOM) then
- nResult = SdFeatureTree(szTitle, szMsg, INSTALLDIR, "", 2);
- if (nResult = BACK) goto Dlg_SdAskDestPath;
- endif;
-
- Dlg_SQL:
- nResult = OnSQLLogin( nResult );
- if( nResult = BACK ) then
- if (!bCustom) then
- goto Dlg_SetupType;
- else
- goto Dlg_SdFeatureTree;
- endif;
- endif;
-
- Dlg_SdStartCopy: //准备就绪对话框
- szTitle = "可以安装“网上阅卷系统”了/b/n安装准备工作已就绪,可以开始安装了。";
- szMsg ="";// "单击“安装”以开始安装。/b/n如果要检查或更改任何安装设置,请单击“上一步”。单击“取消”退出安装向导。";
-
- listStartCopy = ListCreate( STRINGLIST );
- //The following is an example of how to add a string(svName) to a list(listStartCopy).
- //eg. ListAddString(listStartCopy,svName,AFTER);
- ListAddString(listStartCopy,"你的选择如下:",AFTER);
- ListAddString(listStartCopy,"",AFTER);
- ListAddString(listStartCopy,"安装路径:"+TARGETDIR,AFTER);
- ListAddString(listStartCopy,"",AFTER);
- ListAddString(listStartCopy,"程序组名:"+SHELL_OBJECT_FOLDER,AFTER);
- ListAddString(listStartCopy,"",AFTER);
- if (nSetupType = CUSTOM) then
- ListAddString(listStartCopy,"安装类型:"+"自定义",AFTER);
- elseif (nSetupType = TYPICAL) then
- ListAddString(listStartCopy,"安装类型:"+"典型",AFTER);
- elseif (nSetupType = COMPACT) then
- ListAddString(listStartCopy,"安装类型:"+"压缩",AFTER);
- endif;
- nResult = SdStartCopy( szTitle, szMsg, listStartCopy );
- ListDestroy(listStartCopy);
- if (nResult = BACK) then
- goto Dlg_SQL;
- endif;
- //---------------------------------------------------------------------------------
- // 在桌面上添加快捷方式
- AddFolderIcon(FOLDER_DESKTOP,"网上阅卷系统首页","/"http://"+szIp+":8080/Default.aspx/"",TARGETDIR,TARGETDIR+"//TempIco//021.ico",0,"",REPLACE);
- //添加程序快捷方式
- AddFolderIcon(FOLDER_PROGRAMS^"网上阅卷系统GF安装","网上阅卷系统首页","/"http://"+szIp+":8080/Default.aspx/"",TARGETDIR,TARGETDIR+"//TempIco//021.ico",0,"",REPLACE);
- //添加卸载快捷方式
- AddFolderIcon(FOLDER_PROGRAMS^"网上阅卷系统GF安装","卸载","/""+PROGRAMFILES+"/InstallShield Installation Information//{E71A5501-0CCF-4765-A743-8F1352781170}//Setup.exe /"",TARGETDIR,TARGETDIR+"//TempIco//011.ico",0,"",REPLACE);
- // <PROGRAMFILES>/InstallShield Installation Information/{96C6BC6D-1EAA-43C2-9A2C-CB1242590FD7}/Setup.exe
- // 其中
- // {611b4a59-fae0-443b-acbb-8cb1ce57fada}
- // 这个值是这样取得的
- // Project-》Setting-》General-》Project对应的那项
-
- //---------------------------------------------------------------------------------------------------------------
-
- // setup default status
- Enable(STATUSEX);
-
- return 0;
- end;
- //---------------------------------------------------------------------------
- // OnMaintUIAfter
- //
- // The OnMaintUIAfter event called by the framework after the file transfer
- // of the setup when the setup is running in maintenance mode. By default
- // this event displays UI that informs the end user that the maintenance setup
- // has been completed successfully.
- //事件的OnMaintUIAfter所呼吁的框架后,文件传输在安装时,安装程序在维护模式下运行。
- //默认情况下 这一事件显示界面,通知最终用户,维修安装 已成功完成。...
- //---------------------------------------------------------------------------
- function OnMaintUIAfter()
- STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
- NUMBER bOpt1, bOpt2;
- begin
-
- Disable(STATUSEX);
-
- bOpt1 = FALSE;
- bOpt2 = FALSE;
-
- // Added - Version 9.5 - Use appropriate strings for complete
- // uninstall.
- if( REMOVEALLMODE ) then
- szTitle = SdLoadString(IFX_SDFINISH_REMOVE_TITLE);
- szMsg1 = SdLoadString(IFX_SDFINISH_REMOVE_MSG1);
- //卸载完成
- szTitle="卸载完毕";
- szMsg1="已完全卸载“网上阅卷系统”";
- else
- szTitle = SdLoadString(IFX_SDFINISH_MAINT_TITLE);
- szMsg1 = SdLoadString(IFX_SDFINISH_MAINT_MSG1);
- endif;
- szMsg2 ="谢谢您使用保定银河卡电子公司的产品。";
- SdFinishEx(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2);
- end;
- //---------------------------------------------------------------------------
- // OnFirstUIAfter
- //
- // The OnFirstUIAfter event called by the framework after the file transfer
- // of the setup when the setup is running in first install mode. By default
- // this event displays UI that informs the end user that the setup has been
- // completed successfully.
- //事件的OnFirstUIAfter后调用文件transferof安装时,安装程序在第一次安装模式下运行的框架。
- //默认情况下此事件显示界面,通知最终用户,安装程序已成功完成。
- //---------------------------------------------------------------------------
- function OnFirstUIAfter()
- STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
- NUMBER bOpt1, bOpt2;
- string szBmpPath;//自定义
- begin
- szBmpPath=SUPPORTDIR+"//left.bmp;1;0,0,0";
- //SizeWindow (METAFILE,50, 50);
- DialogSetInfo (DLG_INFO_ALTIMAGE, szBmpPath,TRUE); // 设置左边的图片
- Disable(STATUSEX);
- //---------------------------------------
- //安装完成之时
- szTitle = "阅卷系统安装完毕";
- szMsg1 = "谢谢您使用YHK_GF安装程序!!";
- szMsg2 = "已成功安装网“网上阅卷系统”,请单击“完成”以退出安装向导。";
- bOpt1 = FALSE;
- bOpt2 = FALSE;
- szMsg1 = SdLoadString(IFX_SDFINISH_MSG1);
- SdFinishEx(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2);
- end;
- //---------------------------------------------------------------------------
- // OnSQLLogin
- //---------------------------------------------------------------------------
- function number OnSQLLogin( nBtn )
- string sMessage;
- string szConnection,szDB, sTemp[MAX_PATH]; // szServer, szUser, szPassword,
- number nResult, nSize, nCount;
- BOOL bNext; //bWinLogin,
- LIST listConnections;
- STRING svResult,svLine;//自定义
- number nvFileHandle;
- begin
-
- //First initialize SQL Server runtime
- //第一初始化的SQL Server运行
- SQLRTInitialize2();
-
- // Suppress ISSQLSRV.DLL to show a connection error message.
- //禁止ISSQLSRV.DLL显示连接错误信息
- MsiSetProperty( ISMSI_HANDLE, "IS_SQLSERVER_CA_SILENT", "1" );
-
- //Get the names of all the necessary connections
- listConnections = SQLRTGetConnections();
- ListGetFirstString (listConnections, szConnection);
-
- nCount = 0;
-
- //determine if NEXT or BACK will be returned
- //if there are no connections to make
- //确定下一个或返回将被退回
- //如果没有连接
- if( nBtn != BACK ) then
- bNext = TRUE;
- else
- bNext = FALSE;
- //start at end if going BACK
- //退回
- while (ISERR_SUCCESS = ListGetNextString( listConnections, szConnection ) );
- nCount++;
- endwhile;
- endif;
-
-
- // Login for each connection
- //登录每个连接
- while (nResult = ISERR_SUCCESS)
-
- //Get Default values for connection
- //获得连接字符串
- SQLRTGetConnectionInfo( szConnection, szServer, szDB, szUser, szPassword );
-
- bWinLogin = SQLRTGetConnectionAuthentication( szConnection );
-
- // Display login dialog (without connection name)
- //显示登录对话框没有连接名称
- // COMMENT OUT TO SWAP DIALOGS
- //注释外部全系统计划的对话
- nResult = SQLServerSelectLogin2( szConnection, szServer, szUser, szPassword, bWinLogin, szDB, FALSE, TRUE );
- //下面的是只显示 登录用户和密码的不显示数据库和windows登录选择
- //nResult = SQLServerLogin( "", szUser, szPassword );
- // Display login dialog (with connection name)
- //显示登录对话框没有连接名称
- // UNCOMMENT TO SWAP DIALOGS
- //注释外部全系统计划的对话
- // nResult = SQLServerSelectLogin2( szConnection, szServer, szUser, szPassword, bWinLogin, szDB, TRUE, TRUE );
-
- if( nResult = NEXT ) then
-
- //store data in case we need it again
- //保存数据库配置信息,以备下次需要
- SQLRTPutConnectionInfo2( szConnection, szServer, szDB, szUser, szPassword );
-
- SQLRTPutConnectionAuthentication( szConnection, bWinLogin );
-
- //test connection
- //测试连接
- nResult = SQLRTTestConnection2( szConnection, szServer, szDB, szUser, szPassword, bWinLogin );
-
- nSize = MAX_PATH;
- MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_STATUS", sTemp, nSize );
-
- if( sTemp != "0" ) then
-
- nSize = _MAX_PATH;
- MsiGetProperty( ISMSI_HANDLE, "IS_SQLSERVER_STATUS_ERROR", sMessage, nSize );
-
- if( nSize = 0 ) then
- Sprintf(sMessage, SdLoadString( IDS_IFX_SQL_ERROR_LOGIN_FAILED ), szConnection, SdLoadString( ISCRIPT_E_UNKNOWN_ERROR_DESC ));
- endif;
-
- MessageBox( sMessage, MB_OK );
-
- //Show same login dialog again
- //显示相同的数据库登录对话框
- nResult = ListCurrentString(listConnections, szConnection);
-
- else //SUCCESS
- //成功
- //继续下一个连接
- //Move on to next connection
- nCount++;
- bNext = TRUE;
- nResult = ListGetNextString(listConnections, szConnection);
- // MsiSetProperty
- //设置Property里的值
- (ISMSI_HANDLE,"Connection_Property","server="+szServer+";database=wxd;uid="+szUser+";pwd="+szPassword);
-
- endif;
-
- else
-
- //BACK
- //回退
- nCount--;
- bNext = FALSE;
- nResult = ListSetIndex( listConnections, nCount );
- ListCurrentString( listConnections, szConnection );
-
- endif;
-
- endwhile;
-
- if( bNext ) then
- return NEXT;
- else
- return BACK;
- endif;
-
- end;
- //---------------------------------------------------------------------------
- // OnMaintUIBefore
- //
- // The OnMaintUIBefore event is called by the framework 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.
- //该事件被称为OnMaintUIBefore由框架时,安装程序 在维护模式下运行。
- //默认情况下此事件显示界面, 允许最终用户添加或删除功能,目前维修 安装的功能或卸载应用程序。
- //---------------------------------------------------------------------------
- function OnMaintUIBefore()
- NUMBER nResult, nType;
- STRING szTitle, szMsg, svDir, svResult, szCaption;
- //自定义
- STRING szBmpPath;
- begin
- SetTitle("欢迎您使用银河卡电子公司的软件",0, BACKGROUNDCAPTION );//设置标题
-
- //----------------------------------------------------------------
- szBmpPath=SUPPORTDIR+"//left.bmp;1;0,0,0"; //图片有白色的背景,所以设置白色为透明色 “位图文件名;透明标志;<未用>;<未用>;透明色”标准位图为57×53
- //SizeWindow (METAFILE,50, 50);
- DialogSetInfo (DLG_INFO_ALTIMAGE, szBmpPath,TRUE); // 设置左边的logo图片
- //------------------------------------------------------------------
-
- // TO DO: if you want to enable background, window title, and caption bar title
- //如果你要启用的背景,窗口标题,标题和标题栏
- // SetTitle( @PRODUCT_NAME, 24, WHITE );
- // SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION );
- // SetColor(BACKGROUND,RGB (0, 128, 128));
- // Enable( FULLWINDOWMODE );
- // Enable( BACKGROUND );
-
- Dlg_Start:
-
-
- //----------------------------------------------------------------
- //此处为第二次是卸载
- svResult = SdLoadString(IFX_MAINTUI_MSG);
- szCaption = SdLoadString(IFX_ONMAINTUI_CAPTION);
- svResult="是否要完全卸载“网上阅卷系统”?";
- szCaption="确认卸载";
- nResult = SprintfBox(MB_OKCANCEL,szCaption,"%s",svResult);
- if (nResult = IDCANCEL) then
- exit;
- elseif(nResult = IDOK) then
- // setup default status
- SetStatusWindow(0, "");
- Enable(STATUSEX);
- StatusUpdate(ON, 100);
- //-->Remove all components
- ComponentRemoveAll();
- //-------------------------------------------------------------------------------------------
- //分离数据库EXEC sp_detach_db @dbname = '数据库名称'
- //Server=[IS_SQLSERVER_SERVER];User id=[IS_SQLSERVER_USERNAME];Pwd=[IS_SQLSERVER_PASSWORD];DataBase=wxd;Max Pool Size=200;Connect Timeout=300;Connection Lifetime=3;
- //DetachDB();
- //-----------------------------------------------------------------------------------------------------
-
- //----------------------------------------------------------------------------
- DeleteDir(TARGETDIR,ALLCONTENTS);
- DeleteDir(TARGETDIR,ONLYDIR);
-
- //---------------------------------------------------------------------
- endif;
- return 0;
- //------------------------------------------------------------
-
-
- // Added in Version 9.5 - Support for REMOVEONLY option.
- //新增的版本9.5 - 为REMOVEONLY选择支持
- if( !REMOVEONLY ) then
- // In standard mode show maintenance dialog
- //在标准模式对话框显示维修
- Disable(BACKBUTTON);
- nType = SdWelcomeMaint(szTitle, szMsg, MODIFY);
- Enable(BACKBUTTON);
- else
- // Hide the initial progress dialog as otherwise the user can
- // click on it, and hide the MessageBox.
- //隐藏,否则用户的对话,可以初步进展点击它,并隐藏在MessageBox。
- Disable( DIALOGCACHE );
-
- // In RemoveOnly mode, set to remove.
- //在RemoveOnly模式,设置删除
- 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.
- //在非REMOVEONLY模式,重新显示以前的对话。
- goto Dlg_Start;
- endif;
-
- endif;
- endif;
-
- nResult = NEXT;
-
- Dlg_SdFeatureTree:
- if (nType = MODIFY) then
- szTitle = "";
- szMsg = "";
- nResult = SdFeatureTree(szTitle, szMsg, INSTALLDIR, "", 2);
- if (nResult = BACK) goto Dlg_Start;
- endif;
-
- switch(nType)
- case REMOVEALL: FeatureRemoveAll();
- case REPAIR: FeatureReinstall();
- endswitch;
-
- // setup default status
- //设置默认状态
- SetStatusWindow(0, "");
- Enable(STATUSEX);
- StatusUpdate(ON, 100);
- end;
- //---------------------------------------------------------------------------
- // OnUninstall
- //
- // The OnUninstall event is called when the setup is run with the -uninst
- // switch, in this case this is the only event that will be called.
- //该OnUninstall活动名为安装程序时,使用- uninst运行开关,在这种情况下,这是唯一的事件,将被调用。
- //---------------------------------------------------------------------------
- function OnUninstall()
- BOOL bvOpt1, bvOpt2;
- string szTitle, szMsg1, szMsg2, szOpt1, szOpt2, svResult, szCaption;
- begin
- //标题设置
- SetTitle("欢迎您使用银河卡电子产品", 24, WHITE);
-
- //-------------------------------------------------------
- // 在桌面上删除快捷方式
- DeleteFolderIcon (FOLDER_DESKTOP, TARGETDIR+"//TempIco//021.ico");
- //删除程序中的快捷方式
- DeleteFolderIcon(FOLDER_PROGRAMS^"网上阅卷系统GF安装",TARGETDIR+"//TempIco//011.ico");
- //------------------
- svResult = SdLoadString(ISWI_IS5_UNINST_MSG);
- szCaption = SdLoadString(IFX_ONMAINTUI_CAPTION);
- Sprintf (svResult, svResult, @PRODUCT_NAME);
- if (IDCANCEL = SprintfBox(MB_OKCANCEL, szCaption, svResult)) then
- abort;
- endif;
-
- Enable(STATUSEX);
-
- //////////////////////////////////////
- //DO NOT DELETE. The below code will
- //initiate the uninstallation process.
- ComponentRemoveAll();
- ComponentTransferData(MEDIA);
- //////////////////////////////////////
-
- Disable(STATUSEX);
-
- bvOpt1 = FALSE;
- bvOpt2 = FALSE;
- szMsg1 = SdLoadString(IFX_SDFINISH_MAINT_MSG1);
- szTitle = SdLoadString(IFX_SDFINISH_MAINT_TITLE);
- SdFinishEx(szTitle, szMsg1, szMsg2, szOpt1, szOpt2, bvOpt1, bvOpt2);
- //删除安装文件
- DeleteDir(ProgramFilesFolder+"//InstallShield Installation Information//{E71A5501-0CCF-4765-A743-8F1352781170}",ALLCONTENTS);
- DeleteDir(ProgramFilesFolder+"//InstallShield Installation Information//{E71A5501-0CCF-4765-A743-8F1352781170}",ONLYDIR);
-
- end;
-
-
- ///////////////////////////////////////////////////////////////////////
- prototype AttachDB(STRING,STRING,STRING);
- function number AttachDB(svSQLsvr,svSQLusr,svSQLpwd)
- STRING szCmdLine,szWaitTxt;
- begin
- szWaitTxt=" 正在附加所需数据库……";
- SdShowMsg (szWaitTxt, TRUE);
- Delay(2);
- if(bWinLogin) then
- szCmdLine = " /E /S "+svSQLsvr+" /Q /"EXEC sp_attach_db @dbname = N'YCSCMDB',@filename1 = N'"+ProgramFilesFolder^@COMPANY_NAME+"//示例数据库//YCSCMDB_Data.MDF',@filename2 = N'"+ProgramFilesFolder^@COMPANY_NAME+"//示例数据库//YCSCMDB_Log.LDF'/"";
- WriteDBInfo(" /E /S "+svSQLsvr);
- else
- szCmdLine = " /U "+svSQLusr+" /P "+svSQLpwd+" /S "+svSQLsvr+" /Q /"EXEC sp_attach_db @dbname = N'YCSCMDB',@filename1 = N'"+ProgramFilesFolder^@COMPANY_NAME+"//示例数据库//YCSCMDB_Data.MDF',@filename2 = N'"+ProgramFilesFolder^@COMPANY_NAME+"//示例数据库//YCSCMDB_Log.LDF'/"";
- WriteDBInfo(" /U "+svSQLusr+" /P "+svSQLpwd+" /S "+svSQLsvr);
- endif;
- //szCmdLine = "/U "+svSQLusr+" /P "+svSQLpwd+" /S "+svSQLsvr+" /Q /"EXEC sp_attach_db @dbname = N'dlbj',@filename1 = N'"+TARGETDIR ^"dlbj_web.MDF',@filename2 = N'"+TARGETDIR ^"dlbmydb_log.LDF'/"";
-
- if (LaunchAppAndWait("osql.exe", szCmdLine,WAIT) < 0) then
- MessageBox ("数据库附加失败!数据库文件已安装到本地目录,请手动附加!",SEVERE);
- endif;
- SdShowMsg (szWaitTxt, FALSE);
- //szWaitTxt=" 正在优化系统数据库……";
- //SdShowMsg (szWaitTxt, TRUE);
- //Delay(2);
- //szCmdLine = "/U "+svSQLusr+" /P "+svSQLpwd+" /S "+svSQLsvr+" /Q /"use dlbj ; exec sp_updatestats/"";
- // if (LaunchAppAndWait("osql.exe", szCmdLine,WAIT) < 0) then
- // MessageBox ("数据库优化失败!您可以在 sql查询分析器中执行 use dlbj ; exec sp_updatestats 完成!",SEVERE);
- // endif;
- // SdShowMsg (szWaitTxt, FALSE);
-
- return 0;
-
- end;
- //---------------------------------------------------------------------------
- // OnEnd
- //
- // The OnEnd event is called at the end of the setup. This event is not
- // called if the setup is aborted.
- //---------------------------------------------------------------------------
- function OnEnd()
- begin
-
- end;
- //---------------------------------------------------------------------------
- // OnAppSearch
- //
- // The OnAppSearch event is called after OnBegin and can be used to search
- // for previous versions of the current application. This event is called
- // only when the setup is running in first install mode.
- //---------------------------------------------------------------------------
- function OnAppSearch()
- begin
- end;
- //---------------------------------------------------------------------------
- // OnBegin
- //
- // The OnBegin event is called directly by the framework after the setup
- // initializes.
- //---------------------------------------------------------------------------
- function OnBegin()
- begin
- // TO DO: you may change default non-UI setting, for example
- //
- // You may also perform your custom initialization steps, check requirements, etc.
- end;
- //---------------------------------------------------------------------------
- // OnMoving
- //
- // The OnMoving event is called just after the standard MSI action
- // 'InstallInitialize' is executed.
- //---------------------------------------------------------------------------
- function OnMoving()
- begin
- end;
-
-
-
- #include "featureevents.rul"
复制代码
2、FeatureEvents.rul
- //---------------------------------------------------------------------------
- // The Installed event is sent after the feature WebSite
- // is installed.
- //---------------------------------------------------------------------------
-
- export prototype WebSite_Installed();
- function WebSite_Installed()
- begin
- //------------------------------------------------------------------------
- //附加数据库
- if !MAINTENANCE then
- //Server=[IS_SQLSERVER_SERVER];User id=[IS_SQLSERVER_USERNAME];Pwd=[IS_SQLSERVER_PASSWORD];DataBase=wxd;Max Pool Size=200;Connect Timeout=300;Connection Lifetime=3;
- AttachDB( szServer, szUser, szPassword);
- endif;
-
- //---------------------------------------------------------------------------
- end;
- //---------------------------------------------------------------------------
- // The Installing event is sent after the feature WebSite
- // is installed.
- //---------------------------------------------------------------------------
-
- export prototype WebSite_Installing();
- function WebSite_Installing()
-
- begin
-
-
-
- end;
- //---------------------------------------------------------------------------
- // The UnInstalling event is sent just before the feature
- // ExampleDatabase is uninstalled.
- //---------------------------------------------------------------------------
-
- export prototype ExampleDatabase_UnInstalling();
- function ExampleDatabase_UnInstalling()
- begin
- //-------------------------------------------------------------------------------------------
- //分离数据库EXEC sp_detach_db @dbname = '数据库名称'
- //Server=[IS_SQLSERVER_SERVER];User id=[IS_SQLSERVER_USERNAME];Pwd=[IS_SQLSERVER_PASSWORD];DataBase=wxd;Max Pool Size=200;Connect Timeout=300;Connection Lifetime=3;
- //DetachDB();
- //-----------------------------------------------------------------------------------------------------
- end;
- //---------------------------------------------------------------------------
- // The Installing event is sent after the feature ExampleDatabase
- // is installed.
- //---------------------------------------------------------------------------
-
- export prototype ExampleDatabase_Installing();
- function ExampleDatabase_Installing()
- begin
-
-
- end;
- //---------------------------------------------------------------------------
- // The UnInstalled event is sent after the feature ExampleDatabase
- // is uninstalled.
- //---------------------------------------------------------------------------
-
- export prototype ExampleDatabase_UnInstalled();
- function ExampleDatabase_UnInstalled()
- begin
- DeleteDir(ProgramFilesFolder+"//"+@COMPANY_NAME+"//示例数据库",ALLCONTENTS);
- DeleteDir(ProgramFilesFolder+"//"+@COMPANY_NAME+"//示例数据库",ONLYDIR);
- end;
复制代码
|