1+
2+ #include <ISPPBuiltins.iss>
3+ #define AppName " 1Script execution engine"
4+ #define FSFriendlyName " 1Script execution engine"
5+ #define MainExe " TestApp.exe"
6+
7+ #define VerMajor
8+ #define VerMinor
9+ #define VerRelease
10+ #define Build
11+ #expr ParseVersion(" built\" + MainExe,VerMajor,VerMinor,VerRelease,Build)
12+
13+ [Setup]
14+ AppName = {#AppName}
15+ AppVersion = {#VerMajor}.{#VerMinor}.{#VerRelease}
16+ DefaultDirName = " {pf} \{#FSFriendlyName}"
17+ DefaultGroupName = " {#FSFriendlyName}"
18+ DisableProgramGroupPage = yes
19+ UninstallDisplayIcon = " {app} \{#MainExe}"
20+ Compression = lzma2
21+ SolidCompression = yes
22+
23+ [Files]
24+ Source : " built\*" ; DestDir : " {app} "
25+ Source : " dotNetFx40_Full_setup.exe" ; DestDir : {tmp} ; Flags : deleteafterinstall ; Check : not IsRequiredDotNetDetected
26+
27+ [Icons]
28+ Name : " {group} \{#FSFriendlyName}" ; Filename : " {app} \{#MainExe}"
29+
30+ [Run]
31+ Filename : {tmp} \dotNetFx40_Full_setup.exe; Parameters : " /q:a /c:" " install /l /q" " " ; Check : not IsRequiredDotNetDetected; StatusMsg : Microsoft .NET Framework 4.0 is being installed. Please wait..
32+ Filename : " {app} \{#MainExe}" ; Description : " Launch application" ; Flags : postinstall nowait skipifsilent unchecked
33+
34+ [Code]
35+
36+
37+
38+ function IsDotNetDetected (version: string; service: cardinal): boolean;
39+ // Indicates whether the specified version and service pack of the .NET Framework is installed.
40+ //
41+ // version -- Specify one of these strings for the required .NET Framework version:
42+ // 'v1.1.4322' .NET Framework 1.1
43+ // 'v2.0.50727' .NET Framework 2.0
44+ // 'v3.0' .NET Framework 3.0
45+ // 'v3.5' .NET Framework 3.5
46+ // 'v4\Client' .NET Framework 4.0 Client Profile
47+ // 'v4\Full' .NET Framework 4.0 Full Installation
48+ // 'v4.5' .NET Framework 4.5
49+ //
50+ // service -- Specify any non-negative integer for the required service pack level:
51+ // 0 No service packs required
52+ // 1, 2, etc. Service pack 1, 2, etc. required
53+ var
54+ key: string;
55+ install, release, serviceCount: cardinal;
56+ check45, success: boolean;
57+ var reqNetVer : string;
58+ begin
59+ // .NET 4.5 installs as update to .NET 4.0 Full
60+ if version = ' v4.5' then begin
61+ version := ' v4\Full' ;
62+ check45 := true;
63+ end else
64+ check45 := false;
65+
66+ // installation key group for all .NET versions
67+ key := ' SOFTWARE\Microsoft\NET Framework Setup\NDP\' + version;
68+
69+ // .NET 3.0 uses value InstallSuccess in subkey Setup
70+ if Pos(' v3.0' , version) = 1 then begin
71+ success := RegQueryDWordValue(HKLM, key + ' \Setup' , ' InstallSuccess' , install);
72+ end else begin
73+ success := RegQueryDWordValue(HKLM, key, ' Install' , install);
74+ end ;
75+
76+ // .NET 4.0/4.5 uses value Servicing instead of SP
77+ if Pos(' v4' , version) = 1 then begin
78+ success := success and RegQueryDWordValue(HKLM, key, ' Servicing' , serviceCount);
79+ end else begin
80+ success := success and RegQueryDWordValue(HKLM, key, ' SP' , serviceCount);
81+ end ;
82+
83+ // .NET 4.5 uses additional value Release
84+ if check45 then begin
85+ success := success and RegQueryDWordValue(HKLM, key, ' Release' , release);
86+ success := success and (release >= 378389 );
87+ end ;
88+
89+ result := success and (install = 1 ) and (serviceCount >= service);
90+ end ;
91+
92+ function IsRequiredDotNetDetected (): Boolean;
93+ begin
94+ result := IsDotNetDetected(' v4\Full' , 0 );
95+ end ;
96+
97+ function InitializeSetup (): Boolean;
98+ begin
99+ if not IsDotNetDetected(' v4\Full' , 0 ) then begin
100+ MsgBox(' {#AppName} requires Microsoft .NET Framework 4.0 Client Profile.' #13 #13
101+ ' The installer will attempt to install it' , mbInformation, MB_OK);
102+ end ;
103+
104+ result := true;
105+ end ;
0 commit comments