@@ -41,6 +41,7 @@ TParameters = class(TObject, TSettings)
4141 FRegistryPaths : TVStringList;
4242 FEnvironmentVariables : TVStringList;
4343 FFilePaths : TVStringList;
44+ FFilteredPaths : TVStringList;
4445 FLogLevel : TLogLevel;
4546 FIsLogging : Boolean;
4647 FIsDialogDebug : Boolean;
@@ -52,13 +53,15 @@ TParameters = class(TObject, TSettings)
5253 function GetRegistryPaths () : TVStringList;
5354 function GetEnvironmentVariables () : TVStringList;
5455 function GetFilePaths () : TVStringList;
56+ function GetFilteredPaths () : TVStringList;
5557 procedure ParseParams ();
5658 constructor Create();
5759 destructor Destroy(); override;
5860 published
5961 property RegistryPaths : TVStringList read GetRegistryPaths;
6062 property EnvironmentVariables : TVStringList read GetEnvironmentVariables;
6163 property FilePaths : TVStringList read GetFilePaths;
64+ property FilteredPaths : TVStringList read GetFilteredPaths;
6265 property LogLevel : TLogLevel read GetLogLevel;
6366 property IsLogging : Boolean read GetLogging;
6467 property IsDialogDebug : Boolean read GetDialogDebug;
@@ -164,6 +167,11 @@ function TParameters.GetFilePaths() : TVStringList;
164167 Result := FFilePaths;
165168end ;
166169
170+ function TParameters.GetFilteredPaths () : TVStringList;
171+ begin
172+ Result := FFilteredPaths;
173+ end ;
174+
167175function TParameters.ReadParams () : TVStringList;
168176
169177var
@@ -200,13 +208,16 @@ procedure TParameters.ParseParams();
200208 poRegDel = ' /DELREGPATH' ;
201209 poEnv = ' /ENVSTR' ;
202210 poEnvDel = ' /DELENVSTR' ;
211+ poFilterAdd = ' /ADDFILTER' ;
212+ poFilterDel = ' /DELFILTER' ;
203213 poLog = ' /LOG' ;
204214 poDialogDebug = ' /DIALOGDEBUG' ;
205215 poLogLevel = ' /LOGLEVEL' ;
206216
207217var
208218 parameterList : TVStringList;
209219 i : Integer;
220+ s, dialogStr : VString;
210221 tmpLogLevel : TLogLevel;
211222
212223begin
@@ -240,6 +251,18 @@ procedure TParameters.ParseParams();
240251 FEnvironmentVariables.RemoveMatching(parameterList[i + 1 ], False);
241252 Inc(i);
242253 end
254+ else if EqualStr(poFilterAdd, parameterList[i], False) then begin
255+ s := ExpandEnvStrings(parameterList[i + 1 ]);
256+ if (s <> ' ' ) and (s <> parameterList[i + 1 ]) then FFilteredPaths.AddUnique(s, False)
257+ else FFilteredPaths.AddUnique(parameterList[i + 1 ], False);
258+ Inc(i);
259+ end
260+ else if EqualStr(poFilterDel, parameterList[i], False) then begin
261+ FFilteredPaths.RemoveMatching(parameterList[i + 1 ], False);
262+ s := ExpandEnvStrings(parameterList[i + 1 ]);
263+ if (s <> ' ' ) and (s <> parameterList[i + 1 ]) then FFilteredPaths.RemoveMatching(s, False);
264+ Inc(i);
265+ end
243266 else if EqualStr(poLogLevel, parameterList[i], False) then begin
244267 tmpLogLevel := VStrToLogLevel(parameterList[i + 1 ]);
245268 if tmpLogLevel = TLogLevel.INVALID then
@@ -258,6 +281,40 @@ procedure TParameters.ParseParams();
258281 Inc(i);
259282 end ;
260283 parameterList.Free;
284+
285+ for i := 0 to FFilePaths.Count - 1 do begin
286+ s := ExpandEnvStrings(FFilePaths[i]);
287+ if s <> FFilePaths[i] then begin
288+ FFilePaths[i] := s;
289+ end
290+ end ;
291+
292+ if (FIsLogging or FIsDialogDebug) and (FLogLevel >= TLogLevel.DEBUG) then begin
293+ dialogStr := ' ' ;
294+ for i := 0 to FRegistryPaths.Count - 1 do begin
295+ if FIsLogging then LogMessage(' Registry Path ' + IntToVStr(i + 1 ) + ' : ' + FRegistryPaths[i]);
296+ if FIsDialogDebug then dialogStr := dialogStr + ' Registry Path ' + IntToVStr(i + 1 ) + ' : ' + FRegistryPaths[i] + #13 #10 ;
297+ end ;
298+ if dialogStr <> ' ' then NSISDialog(dialogStr, ' Registry Paths' );
299+ dialogStr := ' ' ;
300+ for i := 0 to FEnvironmentVariables.Count - 1 do begin
301+ if FIsLogging then LogMessage(' Environment Variable ' + IntToVStr(i + 1 ) + ' : ' + FEnvironmentVariables[i]);
302+ if FIsDialogDebug then dialogStr := dialogStr + ' Environment Variable ' + IntToVStr(i + 1 ) + ' : ' + FEnvironmentVariables[i] + #13 #10 ;
303+ end ;
304+ if dialogStr <> ' ' then NSISDialog(dialogStr, ' Environment Variables' );
305+ dialogStr := ' ' ;
306+ for i := 0 to FFilePaths.Count - 1 do begin
307+ if FIsLogging then LogMessage(' File Path ' + IntToVStr(i + 1 ) + ' : ' + FFilePaths[i]);
308+ if FIsDialogDebug then dialogStr := dialogStr + ' File Path ' + IntToVStr(i + 1 ) + ' : ' + FFilePaths[i] +#13 #10 ;
309+ end ;
310+ if dialogStr <> ' ' then NSISDialog(dialogStr, ' File Paths' );
311+ dialogStr := ' ' ;
312+ for i := 0 to FFilteredPaths.Count - 1 do begin
313+ if FIsLogging then LogMessage(' Filtered Path ' + IntToVStr(i + 1 ) + ' : ' + FFilteredPaths[i]);
314+ if FIsDialogDebug then dialogStr := dialogStr + ' Filtered Path ' + IntToVStr(i + 1 ) + ' : ' + FFilteredPaths[i] + #13 #10 ;
315+ end ;
316+ if dialogStr <> ' ' then NSISDialog(dialogStr, ' Filtered Paths' );
317+ end ;
261318end ;
262319
263320constructor TParameters.Create();
@@ -340,9 +397,18 @@ constructor TParameters.Create();
340397 ' SOFTWARE\Semeru' ,
341398 ' SOFTWARE\BellSoft\Liberica'
342399 );
400+ StandardFilteredPaths : array [0 ..5 ] of VString = (
401+ ' %commonprogramfiles%\Oracle\Java\javapath' ,
402+ ' %commonprogramfiles(x86)%\Oracle\Java\javapath' ,
403+ ' %commonprogramW6432%\Oracle\Java\javapath' ,
404+ ' %ALLUSERSPROFILE%\Oracle\Java\javapath' ,
405+ ' %SystemRoot%\system32' ,
406+ ' %SystemRoot%\SysWOW64'
407+ );
343408
344409var
345410 i : Integer;
411+ s : VString;
346412
347413begin
348414 FRegistryPaths := TVStringList.Create();
@@ -352,13 +418,20 @@ constructor TParameters.Create();
352418 FEnvironmentVariables := TVStringList.Create();
353419 FEnvironmentVariables.Add(' %JAVA_HOME%' );
354420 FFilePaths := TVStringList.Create();
421+ FFilteredPaths := TVStringList.Create;
422+ for i := 0 to high(StandardFilteredPaths) do begin
423+ s := ExpandEnvStrings(StandardFilteredPaths[i]);
424+ // Only add filters that expand - otherwise they don't exist on the system
425+ if s <> StandardFilteredPaths[i] then FFilteredPaths.AddUnique(s, False);
426+ end ;
355427 FLogLevel := TLogLevel.INFO;
356428 FIsLogging := False;
357429 FIsDialogDebug := False;
358430end ;
359431
360432destructor TParameters.Destroy();
361433begin
434+ FFilteredPaths.Free();
362435 FFilePaths.Free();
363436 FEnvironmentVariables.Free();
364437 FRegistryPaths.Free();
0 commit comments