|
| 1 | +; Script generated by the Inno Setup Script Wizard. |
| 2 | +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! |
| 3 | + |
| 4 | +#define MyAppName "ExcelPython" |
| 5 | +#define MyAppVersion "2.0.6" |
| 6 | +#define MyAppPublisher "ericremoreynolds" |
| 7 | +#define MyAppURL "https://github.com/ericremoreynolds/excelpython" |
| 8 | + |
| 9 | +[Setup] |
| 10 | +; NOTE: The value of AppId uniquely identifies this application. |
| 11 | +; Do not use the same AppId value in installers for other applications. |
| 12 | +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) |
| 13 | +AppId={{729BFC46-B43F-4BA7-9DD2-8D42F116EE9C} |
| 14 | +AppName={#MyAppName} |
| 15 | +AppVersion={#MyAppVersion} |
| 16 | +AppPublisher={#MyAppPublisher} |
| 17 | +AppPublisherURL={#MyAppURL} |
| 18 | +AppSupportURL={#MyAppURL} |
| 19 | +AppUpdatesURL={#MyAppURL} |
| 20 | +LicenseFile=D:\github\excelpython\LICENSE |
| 21 | +OutputDir=D:\github\excelpython\installer |
| 22 | +OutputBaseFilename=excelpython-{#MyAppVersion} |
| 23 | +Compression=lzma |
| 24 | +SolidCompression=yes |
| 25 | +DefaultDirName={code:DefAppFolder} |
| 26 | +UninstallFilesDir={pf}\ExcelPython |
| 27 | + |
| 28 | +DirExistsWarning=no |
| 29 | + |
| 30 | +[Languages] |
| 31 | +Name: "english"; MessagesFile: "compiler:Default.isl" |
| 32 | + |
| 33 | +[Dirs] |
| 34 | +Name: "{app}\xlpython" |
| 35 | + |
| 36 | +[Files] |
| 37 | +Source: "..\addin\xlpython.xlam"; DestDir: "{app}"; Flags: ignoreversion |
| 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 | + |
| 42 | +[Code] |
| 43 | +Function DefAppFolder(Param: String): String; |
| 44 | +Begin |
| 45 | + If DirExists(ExpandConstant('{%APPDATA}\Roaming\Microsoft\Excel\XLSTART')) Then Begin |
| 46 | + Result := ExpandConstant('{%APPDATA}\Roaming\Microsoft\Excel\XLSTART'); |
| 47 | + End Else Begin |
| 48 | + Result := ExpandConstant('{%APPDATA}\Microsoft\Excel\XLSTART'); |
| 49 | + End; |
| 50 | +End; |
| 51 | +
|
| 52 | +// Windows CreateFile function |
| 53 | +function CreateFile( |
| 54 | + lpFileName : String; |
| 55 | + dwDesiredAccess : Cardinal; |
| 56 | + dwShareMode : Cardinal; |
| 57 | + lpSecurityAttributes : Cardinal; |
| 58 | + dwCreationDisposition : Cardinal; |
| 59 | + dwFlagsAndAttributes : Cardinal; |
| 60 | + hTemplateFile : Integer |
| 61 | +): THandle; |
| 62 | +#ifdef UNICODE |
| 63 | + external 'CreateFileW@kernel32.dll stdcall'; |
| 64 | +#else |
| 65 | + external 'CreateFileA@kernel32.dll stdcall'; |
| 66 | +#endif |
| 67 | +
|
| 68 | +// Windows CloseHandle function |
| 69 | +function CloseHandle(hHandle: THandle): BOOL; |
| 70 | +external 'CloseHandle@kernel32.dll stdcall'; |
| 71 | +
|
| 72 | +Const |
| 73 | + GENERIC_WRITE = $40000000; |
| 74 | + { FILE_ATTRIBUTE_NORMAL = $80; } |
| 75 | + OPEN_EXISTING = 3; |
| 76 | + INVALID_HANDLE_VALUE = -1; |
| 77 | +
|
| 78 | +// Function to check if file can be deleted |
| 79 | +Function CanDelete(FileName: String): Boolean; |
| 80 | +Var |
| 81 | + FileHandle: THandle; |
| 82 | +Begin |
| 83 | + 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); |
| 87 | +End; |
| 88 | +
|
| 89 | +// Ensure that the add-in can be deleted |
| 90 | +function InitializeUninstall(): Boolean; |
| 91 | +begin |
| 92 | + Result := false; |
| 93 | + If CanDelete(ExpandConstant('{app}\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 uninstalling.', mbError, MB_OK) |
| 97 | + Result := false; |
| 98 | + End; |
| 99 | +end; |
| 100 | +
|
0 commit comments