[a7de7182] | 1 | [Setup]
|
---|
| 2 | AppName={#AppName}
|
---|
| 3 | AppID={#AppNameLower}
|
---|
| 4 | AppVerName={#AppName} {#AppVersion}
|
---|
| 5 | AppPublisher=PCC Project
|
---|
| 6 | AppPublisherURL=http://pcc.ludd.ltu.se/
|
---|
| 7 | DefaultDirName={pf}\{#AppNameLower}
|
---|
| 8 | DefaultGroupName={#AppName}
|
---|
| 9 | Compression=lzma/ultra
|
---|
| 10 | InternalCompressLevel=ultra
|
---|
| 11 | SolidCompression=yes
|
---|
| 12 | OutputDir=.
|
---|
| 13 | OutputBaseFilename={#AppNameLower}-{#AppVersion}-win32
|
---|
| 14 | ChangesEnvironment=yes
|
---|
| 15 |
|
---|
| 16 | [Files]
|
---|
| 17 | Source: "c:\Program Files\{#AppNameLower}\*.*"; DestDir: {app}; Flags: recursesubdirs
|
---|
| 18 |
|
---|
| 19 | [Icons]
|
---|
| 20 | Name: {group}\{cm:UninstallProgram, {#AppName}}; FileName: {uninstallexe}
|
---|
| 21 |
|
---|
| 22 | [Registry]
|
---|
| 23 | Root: HKLM; Subkey: System\CurrentControlSet\Control\Session Manager\Environment; ValueName: {#AppName}DIR; ValueType: string; ValueData: {app}; Flags: deletevalue
|
---|
| 24 |
|
---|
| 25 | [Tasks]
|
---|
| 26 | Name: modifypath; Description: Add application directory to your system path; Flags: unchecked
|
---|
| 27 |
|
---|
| 28 | [Code]
|
---|
| 29 |
|
---|
| 30 | // Jared Breland <jbreland@legroom.net>
|
---|
| 31 | // http://www.legroom.net/software/modpath
|
---|
| 32 |
|
---|
| 33 | procedure ModPath(BinDir : String);
|
---|
| 34 | var
|
---|
| 35 | oldpath : String;
|
---|
| 36 | newpath : String;
|
---|
| 37 | pathArr : TArrayOfString;
|
---|
| 38 | i : Integer;
|
---|
| 39 | begin
|
---|
| 40 | RegQueryStringValue(HKEY_LOCAL_MACHINE, 'System\CurrentControlSet\Control\Session Manager\Environment', 'Path', oldpath);
|
---|
| 41 | oldpath := oldpath + ';';
|
---|
| 42 | i := 0;
|
---|
| 43 | while (Pos(';', oldpath) > 0) do begin
|
---|
| 44 | SetArrayLength(pathArr, i+1);
|
---|
| 45 | pathArr[i] := Copy(oldpath, 0, Pos(';', oldpath) - 1);
|
---|
| 46 | oldpath := Copy(oldpath, Pos(';', oldpath) + 1, Length(oldpath));
|
---|
| 47 | i := i + 1;
|
---|
| 48 |
|
---|
| 49 | if BinDir = pathArr[i-1] then
|
---|
| 50 | if IsUninstaller() = true then begin
|
---|
| 51 | continue;
|
---|
| 52 | end else begin
|
---|
| 53 | abort;
|
---|
| 54 | end;
|
---|
| 55 |
|
---|
| 56 | if i = 1 then begin
|
---|
| 57 | newpath := pathArr[i-1];
|
---|
| 58 | end else begin
|
---|
| 59 | newpath := newpath + ';' + pathArr[i-1];
|
---|
| 60 | end;
|
---|
| 61 | end;
|
---|
| 62 |
|
---|
| 63 | if IsUninstaller() = false then
|
---|
| 64 | newpath := newpath + ';' + BinDir;
|
---|
| 65 |
|
---|
| 66 | RegWriteStringValue(HKEY_LOCAL_MACHINE, 'System\CurrentControlSet\Control\Session Manager\Environment', 'Path', newpath);
|
---|
| 67 | end;
|
---|
| 68 |
|
---|
| 69 | procedure CurStepChanged(CurStep : TSetupStep);
|
---|
| 70 | var
|
---|
| 71 | appdir : String;
|
---|
| 72 | begin
|
---|
| 73 | if CurStep = ssPostInstall then
|
---|
| 74 | if IsTaskSelected('modifypath') then begin
|
---|
| 75 | appdir := ExpandConstant('{app}');
|
---|
| 76 | ModPath(appdir + '\bin');
|
---|
| 77 | SaveStringToFile(appdir + '\uninsTasks.txt', WizardSelectedTasks(False), False);
|
---|
| 78 | end;
|
---|
| 79 | end;
|
---|
| 80 |
|
---|
| 81 | procedure CurUninstallStepChanged(CurUninstallStep : TUninstallStep);
|
---|
| 82 | var
|
---|
| 83 | appdir : String;
|
---|
| 84 | selectedTasks : String;
|
---|
| 85 | begin
|
---|
| 86 | if CurUninstallStep = usUninstall then begin
|
---|
| 87 | appdir := ExpandConstant('{app}');
|
---|
| 88 | if LoadStringFromFile(appdir + '\uninsTasks.txt', selectedTasks) then
|
---|
| 89 | if (Pos('modifypath', selectedTasks) > 0) then
|
---|
| 90 | ModPath(appdir + '\bin');
|
---|
| 91 | DeleteFile(appdir + '\uninsTasks.txt')
|
---|
| 92 | end;
|
---|
| 93 | end;
|
---|