2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) DIGITEO - 2010-2012 - Allan CORNET
5 // This file must be used under the terms of the CeCILL.
6 // This source file is licensed as described in the file COPYING, which
7 // you should have received as part of this distribution. The terms
8 // are also available at
9 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11 //------------------------------------------------------------------------------
12 // Inno Setup Script (5.3 and more) for Scilab (UNICODE version required)
14 //------------------------------------------------------------------------------
16 function IsProcessorFeaturePresent(ProcessorFeature: DWORD): Boolean;
17 external 'IsProcessorFeaturePresent@kernel32.dll stdcall';
19 function GetModuleHandle(lpModuleName: LongInt): LongInt;
20 external 'GetModuleHandleA@kernel32.dll stdcall';
23 AboutModulesButton: TButton;
24 //------------------------------------------------------------------------------
25 function isCLIType(): Boolean;
28 if (IsComponentSelected( ExpandConstant('{#COMPN_JVM_MODULE}'))) then
33 //------------------------------------------------------------------------------
34 function getExecNameForDesktop(Param: String): String;
36 if (isCLIType() = true) then
38 Result := ExpandConstant('{app}') + '\bin\scilex.exe';
42 Result := ExpandConstant('{app}') + '\bin\wscilex.exe';
45 //------------------------------------------------------------------------------
46 function DoTaskInstall_MKL: Boolean;
49 if (IsComponentSelected( ExpandConstant('{#COMPN_MKL_CPU_LIBRARY}') ) = true) then
51 Result := Install_commons_MKL();
52 if (Result = true) then
54 Result := Install_MKL();
58 //------------------------------------------------------------------------------
59 function DoTaskInstall_MKL_FFTW: Boolean;
62 if (IsComponentSelected( ExpandConstant('{#COMPN_FFTW_MKL_LIBRARY}') ) = true) then
64 Result := Install_MKL_FFTW();
67 //------------------------------------------------------------------------------
68 function DoTaskInstall_CHM: Boolean;
71 if (IsComponentSelected( ExpandConstant('{#COMPN_CHM}') ) = true) then
73 Result := Install_CHM();
76 //------------------------------------------------------------------------------
77 function DoTasksJustAfterInstall: Boolean;
80 Result := CreateModulesFile();
81 Result := DoTaskInstall_MKL();
82 Result := DoTaskInstall_MKL_FFTW();
83 Result := DoTaskInstall_CHM();
85 //------------------------------------------------------------------------------
86 function GetJREVersion(): String;
90 if Is64BitInstallMode() or not IsWin64() then
92 //64 bits installation or 32 bits OS -> same registry path
93 RegQueryStringValue( HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment', 'CurrentVersion', Result );
95 // Scilab 32 bits sur Windows 64 bits
96 RegQueryStringValue( HKLM, 'SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment', 'CurrentVersion', Result );
99 //------------------------------------------------------------------------------
100 function CheckJREVersion(): Boolean;
103 minJREVersionRegistry: String;
106 // Initialize min java version constant
108 minJREVersionRegistry := ExpandConstant('{#javaSpecificationVersion}');
110 // now we check the version of the installed JRE
112 jreVersion := GetJREVersion();
113 if ( jreVersion = '' ) then begin
115 end else if ( jreVersion < minJREVersionRegistry ) then begin
121 //------------------------------------------------------------------------------
122 function VerifyJREVersion() : Boolean;
124 bJREVersion: Boolean;
126 bJREVersion := CheckJREVersion();
128 if ( bJREVersion <> true ) then begin
129 SuppressibleMsgBox( CustomMessage('MsgBoxJavaDetection1') + #13 +
130 CustomMessage('MsgBoxJavaDetection2') + ExpandConstant('{#javaSpecificationVersion}') + '.',
131 mbError, MB_OK, MB_OK );
134 Result := bJREVersion;
136 //------------------------------------------------------------------------------
137 procedure ButtonAboutModulesOnClick(Sender: TObject);
142 if not ShellExec('', ExpandConstant('{#MODULES_LIST_WEB_PAGE}'),
143 '', '', SW_SHOW, ewNoWait, ErrorCode) then
145 // handle failure if necessary
146 SuppressibleMsgBox( CustomMessage('MsgBoxWebOpen'),mbError, MB_OK, MB_OK );
149 //------------------------------------------------------------------------------
150 function BackButtonClick(CurPageID: Integer): Boolean;
153 if (CurPageId = wpSelectProgramGroup) then
155 AboutModulesButton.Visible := true;
157 AboutModulesButton.Visible := false;
160 //------------------------------------------------------------------------------
161 function NextButtonClick_Download_MKL(): Boolean;
166 if (IsComponentSelected( ExpandConstant('{#COMPN_MKL_CPU_LIBRARY}') ) = true) then
168 bRes := Download_commons_MKL();
169 if ( bRes = true ) then
171 bRes := Download_MKL();
175 //------------------------------------------------------------------------------
176 function NextButtonClick_Download_MKL_FFTW(): Boolean;
181 if (IsComponentSelected( ExpandConstant('{#COMPN_FFTW_MKL_LIBRARY}') ) = true) then
183 bRes := Download_MKL_FFTW();
186 //------------------------------------------------------------------------------
187 function NextButtonClick_Download_CHM(): Boolean;
192 if (IsComponentSelected( ExpandConstant('{#COMPN_CHM}') ) = true) then
194 bRes := Download_CHM();
197 //------------------------------------------------------------------------------
198 function NextButtonClick(CurPageID: Integer): Boolean;
205 if (CurPageID = wpWelcome) then
207 if (Is64BitInstallMode() = false) then
211 SuppressibleMsgBox(CustomMessage('MsgBoxX64Ready'), mbInformation, MB_OK, MB_OK );
215 if (IsProcessorFeaturePresent(10) = false) then
218 SuppressibleMsgBox(CustomMessage('MsgBoxSSERequired'), mbError, MB_OK, MB_OK );
223 if (CurPageId = wpSelectDir) then
225 AboutModulesButton.Visible := true;
227 AboutModulesButton.Visible := false;
230 if (CurPageID = wpReady) then
232 bRes := NextButtonClick_Download_MKL();
233 bRes := NextButtonClick_Download_MKL_FFTW();
234 bRes := NextButtonClick_Download_CHM();
237 if (CurPageId = wpSelectComponents) then
239 if ( IsComponentSelected( ExpandConstant('{#COMPN_JRE}') ) = false ) then
241 bRes := VerifyJREVersion();
242 if ( bRes = false ) then
248 if ( (IsComponentSelected( ExpandConstant('{#COMPN_DEVTOOLS}') ) = false) and (IsComponentSelected( ExpandConstant('{#COMPN_TOOLBOX_SKELETON}') ) = true) ) then
250 SuppressibleMsgBox( CustomMessage('MsgBoxDevToolsRequired1') + #13 +
251 CustomMessage('MsgBoxDevToolsRequired2'),
252 mbError, MB_OK, MB_OK );
256 if ( (IsComponentSelected( ExpandConstant('{#COMPN_DEVTOOLS}') ) = false) and (IsComponentSelected( ExpandConstant('{#COMPN_TESTS}') ) = true) ) then
258 SuppressibleMsgBox( CustomMessage('MsgBoxDevToolsRequired3') + #13 +
259 CustomMessage('MsgBoxDevToolsRequired2'),
260 mbError, MB_OK, MB_OK );
266 //------------------------------------------------------------------------------
267 procedure DeinitializeUninstall;
269 Names: TArrayOfString;
272 //read registry to find others scilab installation in the same arch
273 if RegGetSubkeyNames(HKLM, 'Software\Scilab', Names) then
275 iLen := length(Names);
278 RegWriteStringValue(HKLM, 'Software\Scilab', 'LASTINSTALL', Names[iLen - 1]);
280 //no other install in the same arch
281 //remove LASTINSTALL key and Scilab registry folder ( auto )
282 RegDeleteValue(HKLM, 'Software\Scilab', 'LASTINSTALL');
286 //------------------------------------------------------------------------------
287 function InitializeSetup: Boolean;
289 Version: TWindowsVersion;
290 #ifdef SCILAB_WITHOUT_JRE
295 GetWindowsVersionEx(Version);
297 if Version.NTPlatform and (Version.Major > 4) then
301 SuppressibleMsgBox(CustomMessage('MsgBoxWinVer'), mbCriticalError, MB_OK, MB_OK);
305 #ifdef SCILAB_WITHOUT_JRE
306 bRes := CheckJREVersion();
307 if ( bRes = false ) then
309 SuppressibleMsgBox(CustomMessage('MsgBoxJRENotFound')+ '(' +ExpandConstant('{#javaSpecificationVersion}') + ')' + #13 +
310 CustomMessage('MsgBoxJREURL')+ #13 +
311 CustomMessage('MsgBoxJREReinstall')
312 , mbCriticalError, MB_OK, MB_OK);
320 //------------------------------------------------------------------------------
321 procedure CreateTheWizardPages;
323 CancelButton: TButton;
327 CancelButton := WizardForm.CancelButton;
329 AboutModulesButton := TButton.Create(WizardForm);
330 AboutModulesButton.Left := WizardForm.ClientWidth - CancelButton.Left - CancelButton.Width;
331 AboutModulesButton.Top := CancelButton.Top;
332 AboutModulesButton.Width := CancelButton.Width * 2;
334 AboutModulesButton.Caption := CustomMessage('ButtonAboutModules');
336 AboutModulesButton.Height := CancelButton.Height;
338 AboutModulesButton.OnClick := @ButtonAboutModulesOnClick;
339 AboutModulesButton.Parent := CancelButton.Parent;
340 AboutModulesButton.Visible := false;
342 //------------------------------------------------------------------------------
343 procedure InitializeWizard();
346 CreateTheWizardPages;
348 //------------------------------------------------------------------------------
349 //convert Boolean expresion in string ( debug function )
350 function BoolToStr(Value : Boolean) : String;
357 //------------------------------------------------------------------------------
359 function IsAdminUser(): Boolean;
361 Result := (IsAdminLoggedOn or IsPowerUserLoggedOn);
363 //------------------------------------------------------------------------------
364 //returns default install path ( take care of user rights )
365 function DefDirRoot(Param: String): String;
369 Result := ExpandConstant('{pf}')
371 //local app data path
372 Result := ExpandConstant('{localappdata}')