2
2
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
3
3
4
4
#define MyAppName " ExcelPython"
5
- #define MyAppVersion " 2.0.7 "
5
+ #define MyAppVersion " 2.0.8 "
6
6
#define MyAppPublisher " ericremoreynolds"
7
7
#define MyAppURL " https://github.com/ericremoreynolds/excelpython"
8
8
@@ -23,8 +23,8 @@ OutputBaseFilename=excelpython-{#MyAppVersion}
23
23
Compression = lzma
24
24
SolidCompression = yes
25
25
DefaultDirName = {code:DefAppFolder}
26
- UninstallFilesDir = {pf } \ExcelPython
27
-
26
+ UninstallFilesDir = {userappdata }\ExcelPython
27
+ PrivilegesRequired = lowest
28
28
DirExistsWarning = no
29
29
30
30
[Languages]
@@ -36,8 +36,6 @@ Name: "{app}\xlpython"
36
36
[Files]
37
37
Source : " ..\addin\xlpython.xlam" ; DestDir : " {app} " ; Flags : ignoreversion
38
38
Source : " ..\addin\xlpython\*" ; DestDir : " {app} \xlpython" ; Flags : ignoreversion recursesubdirs createallsubdirs
39
- ; Source: IssProc.dll; DestDir: "{tmp}"; Flags: dontcopy
40
- ; Source: IssProc.dll; DestDir: "{pf}\ExcelPython"
41
39
42
40
[Code]
43
41
Function DefAppFolder (Param: String): String;
81
79
FileHandle: THandle;
82
80
Begin
83
81
Result := False;
84
- FileHandle := CreateFile(FileName, GENERIC_WRITE, 0 , 0 , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
85
- Result := (FileHandle <> INVALID_HANDLE_VALUE);
86
- If Result Then CloseHandle(FileHandle);
82
+ If Not FileExists(FileName) Then Begin
83
+ Result := True;
84
+ End Else Begin
85
+ FileHandle := CreateFile(FileName, GENERIC_WRITE, 0 , 0 , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
86
+ Result := (FileHandle <> INVALID_HANDLE_VALUE);
87
+ If Result Then CloseHandle(FileHandle);
88
+ End ;
89
+ End ;
90
+
91
+ Function InitializeSetup (): Boolean;
92
+ Begin
93
+ If CanDelete(DefAppFolder(' ' ) + ' \xlpython.xlam' ) Then Begin
94
+ Result := true;
95
+ End Else Begin
96
+ MsgBox(' ExcelPython appears to be in use - please make sure you close all instances of Excel before proceeding.' , mbError, MB_OK)
97
+ Result := false;
98
+ End ;
87
99
End ;
88
100
89
101
// Ensure that the add-in can be deleted
@@ -93,8 +105,56 @@ begin
93
105
If CanDelete(ExpandConstant(' {app}\xlpython.xlam' )) Then Begin
94
106
Result := true;
95
107
End Else Begin
96
- MsgBox(' ExcelPython appears to be in use - please make sure you close all instances of Excel before uninstalling .' , mbError, MB_OK)
108
+ MsgBox(' ExcelPython appears to be in use - please make sure you close all instances of Excel before proceeding .' , mbError, MB_OK)
97
109
Result := false;
98
110
End ;
99
111
end ;
100
112
113
+ // ///////////////////////////////////////////////////////////////////
114
+ function GetUninstallString (): String;
115
+ var
116
+ sUnInstPath: String;
117
+ sUnInstallString: String;
118
+ begin
119
+ sUnInstPath := ExpandConstant(' Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1' );
120
+ sUnInstallString := ' ' ;
121
+ if not RegQueryStringValue(HKLM, sUnInstPath, ' UninstallString' , sUnInstallString) then
122
+ RegQueryStringValue(HKCU, sUnInstPath, ' UninstallString' , sUnInstallString);
123
+ Result := sUnInstallString;
124
+ end ;
125
+
126
+
127
+ // ///////////////////////////////////////////////////////////////////
128
+ function UnInstallOldVersion (): Integer;
129
+ var
130
+ sUnInstallString: String;
131
+ iResultCode: Integer;
132
+ begin
133
+ // Return Values:
134
+ // 1 - uninstall string is empty
135
+ // 2 - error executing the UnInstallString
136
+ // 3 - successfully executed the UnInstallString
137
+
138
+ // default return value
139
+ Result := 0 ;
140
+
141
+ // get the uninstall string of the old app
142
+ sUnInstallString := GetUninstallString();
143
+ if sUnInstallString <> ' ' then begin
144
+ sUnInstallString := RemoveQuotes(sUnInstallString);
145
+ if Exec(sUnInstallString, ' /SILENT /NORESTART /SUPPRESSMSGBOXES' ,' ' , SW_HIDE, ewWaitUntilTerminated, iResultCode) then
146
+ Result := 3
147
+ else
148
+ Result := 2 ;
149
+ end else
150
+ Result := 1 ;
151
+ end ;
152
+
153
+ // ///////////////////////////////////////////////////////////////////
154
+ Procedure CurStepChanged (CurStep: TSetupStep);
155
+ Begin
156
+ If (CurStep=ssInstall) Then Begin
157
+ UnInstallOldVersion();
158
+ End ;
159
+ End ;
160
+
0 commit comments