Setup.Rul 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. //===========================================================================
  2. //
  3. // File Name: Setup.rul
  4. //
  5. // Description: Blank setup main script file
  6. //
  7. // Comments: Blank setup is an empty setup project. If you want to
  8. // create a new project via. step-by step instructions use the
  9. // Project Assistant.
  10. //
  11. //===========================================================================
  12. // Included header files ----------------------------------------------------
  13. #include "ifx.h"
  14. #include "IpAddress.rul"
  15. #include "featureevents.rul"
  16. //---------------------------------------------------------------------------
  17. // OnFirstUIBefore
  18. //
  19. // First Install UI Sequence - Before Move Data
  20. //
  21. // The OnFirstUIBefore event is called by OnShowUI when the setup is
  22. // running in first install mode. By default this event displays UI allowing
  23. // the end user to specify installation parameters.
  24. //
  25. // Note: This event will not be called automatically in a
  26. // program...endprogram style setup.
  27. //---------------------------------------------------------------------------
  28. function OnFirstUIBefore()
  29. number nResult, nLevel, nSize, nSetupType;
  30. string szTitle, szMsg, szOpt1, szOpt2, szLicenseFile;
  31. string szName, szCompany, szTargetPath, szDir, szFeatures;
  32. BOOL bLicenseAccepted;
  33. begin
  34. nSetupType = COMPLETE;
  35. szDir = TARGETDIR;
  36. szName = "";
  37. szCompany = "";
  38. bLicenseAccepted = FALSE;
  39. // Beginning of UI Sequence
  40. Dlg_Start:
  41. nResult = 0;
  42. Dlg_SdWelcome:
  43. szTitle = "";
  44. szMsg = "";
  45. //{{IS_SCRIPT_TAG(Dlg_SdWelcome)
  46. nResult = SdWelcome( szTitle, szMsg );
  47. //}}IS_SCRIPT_TAG(Dlg_SdWelcome)
  48. if (nResult = BACK) goto Dlg_Start;
  49. Dlg_SdLicense2:
  50. szTitle = "";
  51. szOpt1 = "";
  52. szOpt2 = "";
  53. //{{IS_SCRIPT_TAG(License_File_Path)
  54. szLicenseFile = SUPPORTDIR ^ "License.rtf";
  55. //}}IS_SCRIPT_TAG(License_File_Path)
  56. //{{IS_SCRIPT_TAG(Dlg_SdLicense2)
  57. // nResult = SdLicense2Rtf( szTitle, szOpt1, szOpt2, szLicenseFile, bLicenseAccepted );
  58. //}}IS_SCRIPT_TAG(Dlg_SdLicense2)
  59. if (nResult = BACK) then
  60. goto Dlg_SdWelcome;
  61. else
  62. bLicenseAccepted = TRUE;
  63. endif;
  64. Dlg_SdRegisterUser:
  65. szMsg = "";
  66. szTitle = "";
  67. //{{IS_SCRIPT_TAG(Dlg_SdRegisterUser)
  68. // nResult = SdRegisterUser( szTitle, szMsg, szName, szCompany );
  69. //}}IS_SCRIPT_TAG(Dlg_SdRegisterUser)
  70. if (nResult = BACK) goto Dlg_SdLicense2;
  71. Dlg_SetupType2:
  72. szTitle = "";
  73. szMsg = "";
  74. nResult = CUSTOM;
  75. //{{IS_SCRIPT_TAG(Dlg_SetupType2)
  76. nResult = SetupType2( szTitle, szMsg, "", nSetupType, 0 );
  77. //}}IS_SCRIPT_TAG(Dlg_SetupType2)
  78. if (nResult = BACK) then
  79. goto Dlg_SdRegisterUser;
  80. else
  81. nSetupType = nResult;
  82. if (nSetupType != CUSTOM) then
  83. szTargetPath = TARGETDIR;
  84. nSize = 0;
  85. FeatureCompareSizeRequired( MEDIA, szTargetPath, nSize );
  86. if (nSize != 0) then
  87. MessageBox( szSdStr_NotEnoughSpace, WARNING );
  88. goto Dlg_SetupType2;
  89. endif;
  90. endif;
  91. endif;
  92. Dlg_SdAskDestPath2:
  93. if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType2;
  94. szTitle = "";
  95. szMsg = "";
  96. if (nSetupType = CUSTOM) then
  97. //{{IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
  98. nResult = SdAskDestPath2( szTitle, szMsg, szDir );
  99. //}}IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
  100. TARGETDIR = szDir;
  101. endif;
  102. if (nResult = BACK) goto Dlg_SetupType2;
  103. Dlg_SdFeatureTree:
  104. if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdAskDestPath2;
  105. szTitle = "";
  106. szMsg = "";
  107. szFeatures = "";
  108. nLevel = 2;
  109. if (nSetupType = CUSTOM) then
  110. //{{IS_SCRIPT_TAG(Dlg_SdFeatureTree)
  111. nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, szFeatures, nLevel );
  112. //}}IS_SCRIPT_TAG(Dlg_SdFeatureTree)
  113. if (nResult = BACK) goto Dlg_SdAskDestPath2;
  114. endif;
  115. Dlg_SQLServer:
  116. nResult = OnSQLServerInitialize( nResult );
  117. if( nResult = BACK ) goto Dlg_SdFeatureTree;
  118. Dlg_ObjDialogs:
  119. nResult = ShowObjWizardPages( nResult );
  120. if (nResult = BACK) goto Dlg_SQLServer;
  121. Dlg_SdStartCopy2:
  122. szTitle = "";
  123. szMsg = "";
  124. //{{IS_SCRIPT_TAG(Dlg_SdStartCopy2)
  125. nResult = SdStartCopy2( szTitle, szMsg );
  126. //}}IS_SCRIPT_TAG(Dlg_SdStartCopy2)
  127. if (nResult = BACK) goto Dlg_ObjDialogs;
  128. // Added in 11.0 - Set appropriate StatusEx static text.
  129. SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );
  130. return 0;
  131. end;
  132. //---------------------------------------------------------------------------
  133. // OnSetTARGETDIR
  134. //
  135. // OnSetTARGETDIR is called directly by the framework to initialize
  136. // TARGETDIR to it's default value.
  137. //
  138. // Note: This event is called for all setups.
  139. //---------------------------------------------------------------------------
  140. function OnSetTARGETDIR()
  141. number nId, nIgnore, nResult;
  142. string szId, szTARGETDIR;
  143. string svCurrentDir; // 默认的安装目录;
  144. begin
  145. // In maintenance mode the value of TARGETDIR is read from the log file.
  146. if( MAINTENANCE ) then
  147. return ISERR_SUCCESS;
  148. endif;
  149. fGetIpAddress(szId, svCurrentDir);
  150. // 重新定义安装的默认目录;
  151. GetCurrentDir( svCurrentDir );
  152. // 获取字段串长度;
  153. nId = StrLength(svCurrentDir);
  154. // 获取路径最后一个字符;
  155. StrSub(szId, svCurrentDir,nId - 1, nId);
  156. // 判断最后一个字符是否为"\\";
  157. if (szId == "\\") then
  158. TARGETDIR = svCurrentDir + "<IFX_COMPANY_NAME>\\<IFX_PRODUCT_NAME>";
  159. else
  160. TARGETDIR = svCurrentDir + "\\<IFX_COMPANY_NAME>\\<IFX_PRODUCT_NAME>";
  161. endif;
  162. // Read TARGETDIR from the media.
  163. nResult = MediaGetData( MEDIA, MEDIA_FIELD_TARGETDIR, nIgnore, szTARGETDIR );
  164. // Customize the default TARGETDIR for multi-instance application.
  165. // TODO: If you want something different customize the code below.
  166. if( MAINT_OPTION = MAINT_OPTION_MULTI_INSTANCE && MULTI_INSTANCE_COUNT > 0) then
  167. // Start with the current multi-instance count plus one.
  168. nId = MULTI_INSTANCE_COUNT + 1;
  169. // Find a unique TARGETDIR.
  170. while( ExistsDir( TARGETDIR ) = EXISTS )
  171. // Convert to string.
  172. NumToStr( szId, nId );
  173. // Update IFX_MULTI_INSTANCE_SUFFIX
  174. IFX_MULTI_INSTANCE_SUFFIX = "_" + szId;
  175. // Update TARGETDIR
  176. TARGETDIR = TARGETDIR + IFX_MULTI_INSTANCE_SUFFIX;
  177. // Update nId
  178. nId = nId + 1;
  179. endwhile;
  180. endif;
  181. end;