@@ -27,8 +27,8 @@ ArchitecturesInstallIn64BitMode=x64
27
27
MinVersion = 6.0
28
28
29
29
[Files]
30
- Source : " hectane-386.exe" ; DestDir : " {app} " ; DestName : " {#AppExe}" ; Check : not Is64BitInstallMode
31
- Source : " hectane-amd64.exe" ; DestDir : " {app} " ; DestName : " {#AppExe}" ; Check : Is64BitInstallMode
30
+ Source : " hectane-386.exe" ; DestDir : " {app} " ; DestName : " {#AppExe}" ; Check : not Is64BitInstallMode; BeforeInstall : PreInstall; AfterInstall : PostInstall
31
+ Source : " hectane-amd64.exe" ; DestDir : " {app} " ; DestName : " {#AppExe}" ; Check : Is64BitInstallMode; BeforeInstall : PreInstall; AfterInstall : PostInstall
32
32
33
33
[Code]
34
34
@@ -42,21 +42,33 @@ begin
42
42
Result := Exec(ExpandConstant(' {app}\{#AppExe}' ), Command, ' ' , SW_HIDE, ewWaitUntilTerminated, ResultCode);
43
43
end ;
44
44
45
- procedure CurStepChanged (CurStep: TSetupStep);
45
+ // The service should only be installed if the executable didn't exist before
46
+ // installation. A global variable is required to keep track of this so that
47
+ // after installation, the appropriate action can be taken.
48
+
49
+ var
50
+ FileExisted: Boolean;
51
+
52
+ procedure PreInstall ();
53
+ begin
54
+ FileExisted := FileExists(ExpandConstant(' {app}\{#AppExe}' ));
55
+ end ;
56
+
57
+ // The service will automatically be stopped and restarted by the Restart
58
+ // Manager if it was running prior to installation.
59
+
60
+ procedure PostInstall ();
46
61
begin
47
- if CurStep = ssPostInstall then
62
+ if not FileExisted then
48
63
begin
49
- if not RmSessionStarted() then
64
+ WizardForm.StatusLabel.Caption := ' Installing & starting service...' ;
65
+ if ServiceCommand(ExpandConstant(' -directory "{app}\data" install' )) then
50
66
begin
51
- WizardForm.StatusLabel.Caption := ' Installing & starting service...' ;
52
- if ServiceCommand(ExpandConstant(' -directory "{app}\data" install' )) then
53
- begin
54
- if not ServiceCommand(' start' ) then
55
- MsgBox(' Unable to start service.' , mbError, MB_OK);
56
- end
57
- else
58
- MsgBox(' Unable to install service.' , mbError, MB_OK);
59
- end ;
67
+ if not ServiceCommand(' start' ) then
68
+ MsgBox(' Unable to start service.' , mbError, MB_OK);
69
+ end
70
+ else
71
+ MsgBox(' Unable to install service.' , mbError, MB_OK);
60
72
end ;
61
73
end ;
62
74
0 commit comments