1- // Template file used by the create-installer.ps1 script
1+ // File used by the create-installer.ps1 script
22
3+ #include " create-installer.isi"
4+ // Must have:
35// #define MyVersionShownName " <shared|static> (<32|64> bit)"
46// #define MyVersionCodeName " <shared|static>-<32|64>"
57// #define MyIs64bit <true|false>
68// #define MyGettextVer " <gettext version>"
79// #define MyIconvVer " <iconv version>"
810// #define MyCompiledFolderPath " <path>"
11+ // #define MyOutputFolderPath " <path>"
12+ // #define MyLanguages " Entries of the [Languages] section"
913
1014[Setup]
1115AppId = gettext-iconv
1216AppName = " gettext + iconv"
1317AppVerName = " gettext {#MyGettextVer} + iconv {#MyIconvVer} - {#MyVersionShownName}"
14- DefaultDirName = {commonpf}\gettext-iconv
18+ WizardStyle = modern dynamic
19+ DefaultDirName = {autopf}\gettext-iconv
1520AppPublisher = Michele Locati
1621AppPublisherURL = https://github.com/mlocati
17- AppSupportURL = https://github.com/mlocati/gettext-iconv-windows
22+ AppSupportURL = https://github.com/mlocati/gettext-iconv-windows/issues
1823AppUpdatesURL = https://github.com/mlocati/gettext-iconv-windows/releases
1924#if MyIs64bit
2025ArchitecturesAllowed = x64
2126ArchitecturesInstallIn64BitMode = x64
2227#endif
23- ChangesEnvironment = yes
28+ ChangesEnvironment = WizardIsTaskSelected(' modifypath' ) or WizardIsTaskSelected(' setenvcldr' )
29+ PrivilegesRequiredOverridesAllowed= commandline dialog
2430Compression = lzma2 /max
2531LicenseFile = {#MyCompiledFolderPath}\license.txt
26- OutputDir = setup
32+ OutputDir = {#MyOutputFolderPath}
2733OutputBaseFilename = gettext{#MyGettextVer}-iconv{#MyIconvVer}-{#MyVersionCodeName}
2834VersionInfoProductTextVersion = 1.0
35+ ShowLanguageDialog = auto
2936
3037[Files]
3138Source : " {#MyCompiledFolderPath}\*.*" ; DestDir : " {app} " ; Flags : recursesubdirs
3239
3340[Tasks]
34- Name : modifypath; Description : &Add application directory to your environmental &PATH
35- Name : setenvcldr; Description : Set GETTEXTCLDRDIR environment variable (useful for msginit)
41+ Name : modifypath; Description : " {cm:ModifyPath}"
42+ Name : setenvcldr; Description : " {cm:SetEnvCLDR}"
43+
44+ [Languages]
45+ {#MyLanguages}
46+
3647
3748[Code]
3849#ifdef UNICODE
4657 TASK_SETENVCLDR = ' setenvcldr' ;
4758 TASK_MODPATH_TYPE = ' system' ;
4859 TASK_SETENVCLDR_NAME = ' GETTEXTCLDRDIR' ;
49- TASK_SETENVCLDR_TYPE = ' system' ;
5060
5161function SetEnvironmentVariable (lpName: string; lpValue: string): BOOL;
5262 external ' SetEnvironmentVariable{#AW}@kernel32.dll stdcall' ;
7484 regroot: Integer;
7585 regpath: String;
7686begin
77- if TASK_SETENVCLDR_TYPE = ' system ' then begin
87+ if IsAdminInstallMode then begin
7888 regroot := HKEY_LOCAL_MACHINE;
7989 regpath := ' SYSTEM\CurrentControlSet\Control\Session Manager\Environment' ;
8090 end else begin
97107 newpath: String;
98108 updatepath: Boolean;
99109 pathArr: TArrayOfString;
100- aExecFile: String;
101- aExecArr: TArrayOfString;
102110 i, d: Integer;
103111 pathdir: TArrayOfString;
104112 regroot: Integer;
105113 regpath: String;
106114
107115begin
108116 // Get constants from main script and adjust behavior accordingly
109- // TASK_MODPATH_TYPE MUST be 'system' or 'user'; force 'user' if invalid
110- if TASK_MODPATH_TYPE = ' system' then begin
117+ if IsAdminInstallMode then begin
111118 regroot := HKEY_LOCAL_MACHINE;
112119 regpath := ' SYSTEM\CurrentControlSet\Control\Session Manager\Environment' ;
113120 end else begin
@@ -120,78 +127,41 @@ begin
120127 for d := 0 to GetArrayLength(pathdir)-1 do begin
121128 updatepath := true;
122129
123- // Modify WinNT path
124- if UsingWinNT() = true then begin
125-
126- // Get current path, split into an array
127- RegQueryStringValue(regroot, regpath, ' Path' , oldpath);
128- oldpath := oldpath + ' ;' ;
129- i := 0 ;
130-
131- while (Pos(' ;' , oldpath) > 0 ) do begin
132- SetArrayLength(pathArr, i+1 );
133- pathArr[i] := Copy(oldpath, 0 , Pos(' ;' , oldpath)-1 );
134- oldpath := Copy(oldpath, Pos(' ;' , oldpath)+1 , Length(oldpath));
135- i := i + 1 ;
136-
137- // Check if current directory matches app dir
138- if pathdir[d] = pathArr[i-1 ] then begin
139- // if uninstalling, remove dir from path
140- if IsUninstaller() = true then begin
141- continue;
142- // if installing, flag that dir already exists in path
143- end else begin
144- updatepath := false;
145- end ;
146- end ;
147-
148- // Add current directory to new path
149- if i = 1 then begin
150- newpath := pathArr[i-1 ];
151- end else begin
152- newpath := newpath + ' ;' + pathArr[i-1 ];
153- end ;
154- end ;
155-
156- // Append app dir to path if not already included
157- if (IsUninstaller() = false) AND (updatepath = true) then
158- newpath := newpath + ' ;' + pathdir[d];
159- // Write new path
160- RegWriteStringValue(regroot, regpath, ' Path' , newpath);
161-
162- // Modify Win9x path
163- end else begin
164-
165- // Convert to shortened dirname
166- pathdir[d] := GetShortName(pathdir[d]);
167-
168- // If autoexec.bat exists, check if app dir already exists in path
169- aExecFile := ' C:\AUTOEXEC.BAT' ;
170- if FileExists(aExecFile) then begin
171- LoadStringsFromFile(aExecFile, aExecArr);
172- for i := 0 to GetArrayLength(aExecArr)-1 do begin
173- if IsUninstaller() = false then begin
174- // If app dir already exists while installing, skip add
175- if (Pos(pathdir[d], aExecArr[i]) > 0 ) then
176- updatepath := false;
177- break;
178- end else begin
179- // If app dir exists and = what we originally set, then delete at uninstall
180- if aExecArr[i] = ' SET PATH=%PATH%;' + pathdir[d] then
181- aExecArr[i] := ' ' ;
182- end ;
183- end ;
184- end ;
185-
186- // If app dir not found, or autoexec.bat didn't exist, then (create and) append to current path
187- if (IsUninstaller() = false) AND (updatepath = true) then begin
188- SaveStringToFile(aExecFile, #13 #10 + ' SET PATH=%PATH%;' + pathdir[d], True);
189-
190- // If uninstalling, write the full autoexec out
191- end else begin
192- SaveStringsToFile(aExecFile, aExecArr, False);
193- end ;
194- end ;
130+ // Get current path, split into an array
131+ RegQueryStringValue(regroot, regpath, ' Path' , oldpath);
132+ oldpath := oldpath + ' ;' ;
133+ i := 0 ;
134+
135+ while (Pos(' ;' , oldpath) > 0 ) do begin
136+ SetArrayLength(pathArr, i+1 );
137+ pathArr[i] := Copy(oldpath, 0 , Pos(' ;' , oldpath)-1 );
138+ oldpath := Copy(oldpath, Pos(' ;' , oldpath)+1 , Length(oldpath));
139+ i := i + 1 ;
140+
141+ // Check if current directory matches app dir
142+ if pathdir[d] = pathArr[i-1 ] then begin
143+ // if uninstalling, remove dir from path
144+ if IsUninstaller() = true then begin
145+ continue;
146+ // if installing, flag that dir already exists in path
147+ end else begin
148+ updatepath := false;
149+ end ;
150+ end ;
151+
152+ // Add current directory to new path
153+ if i = 1 then begin
154+ newpath := pathArr[i-1 ];
155+ end else begin
156+ newpath := newpath + ' ;' + pathArr[i-1 ];
157+ end ;
158+ end ;
159+
160+ // Append app dir to path if not already included
161+ if (IsUninstaller() = false) AND (updatepath = true) then
162+ newpath := newpath + ' ;' + pathdir[d];
163+ // Write new path
164+ RegWriteStringValue(regroot, regpath, ' Path' , newpath);
195165 end ;
196166end ;
197167
@@ -256,12 +226,3 @@ begin
256226 end ;
257227 end ;
258228end ;
259-
260- function NeedRestart (): Boolean;
261- begin
262- if (WizardIsTaskSelected(TASK_MODPATH) or WizardIsTaskSelected(TASK_SETENVCLDR)) and not UsingWinNT() then begin
263- Result := True;
264- end else begin
265- Result := False;
266- end ;
267- end ;
0 commit comments