Browse Source

Cleanup unused ReadOnly parameter of GetShellFolder. Also fixes issues with previous cleanup.

Martijn Laan 1 năm trước cách đây
mục cha
commit
1b6b0090e5

+ 1 - 1
Projects/Install.pas

@@ -314,7 +314,7 @@ var
   FontDir: String;
   FontDir: String;
 begin
 begin
   Result := PathExpand(Filename);
   Result := PathExpand(Filename);
-  FontDir := GetShellFolder(False, sfFonts, False);
+  FontDir := GetShellFolder(False, sfFonts);
   if FontDir <> '' then
   if FontDir <> '' then
     if PathCompare(PathExtractDir(Result), FontDir) = 0 then
     if PathCompare(PathExtractDir(Result), FontDir) = 0 then
       Result := PathExtractName(Result);
       Result := PathExtractName(Result);

+ 7 - 10
Projects/Main.pas

@@ -210,8 +210,7 @@ function ExpandConstEx2(const S: String; const CustomConsts: array of String;
   const DoExpandIndividualConst: Boolean): String;
   const DoExpandIndividualConst: Boolean): String;
 function ExpandConstIfPrefixed(const S: String): String;
 function ExpandConstIfPrefixed(const S: String): String;
 function GetCustomMessageValue(const AName: String; var AValue: String): Boolean;
 function GetCustomMessageValue(const AName: String; var AValue: String): Boolean;
-function GetShellFolder(const Common: Boolean; const ID: TShellFolderID;
-  ReadOnly: Boolean): String;
+function GetShellFolder(const Common: Boolean; const ID: TShellFolderID): String;
 function GetShellFolderByCSIDL(Folder: Integer; const Create: Boolean): String;
 function GetShellFolderByCSIDL(Folder: Integer; const Create: Boolean): String;
 function GetUninstallRegKeyBaseName(const ExpandedAppId: String): String;
 function GetUninstallRegKeyBaseName(const ExpandedAppId: String): String;
 function GetUninstallRegSubkeyName(const UninstallRegKeyBaseName: String): String;
 function GetUninstallRegSubkeyName(const UninstallRegKeyBaseName: String): String;
@@ -1145,7 +1144,7 @@ begin
       if WizardGroupValue = '' then
       if WizardGroupValue = '' then
         InternalError('An attempt was made to expand the "' + OriginalCnst + '" constant before it was initialized');
         InternalError('An attempt was made to expand the "' + OriginalCnst + '" constant before it was initialized');
       ShellFolder := GetShellFolder(not(shAlwaysUsePersonalGroup in SetupHeader.Options) and IsAdminInstallMode,
       ShellFolder := GetShellFolder(not(shAlwaysUsePersonalGroup in SetupHeader.Options) and IsAdminInstallMode,
-        sfPrograms, False);
+        sfPrograms);
       if ShellFolder = '' then
       if ShellFolder = '' then
         InternalError('Failed to expand "' + OriginalCnst + '" constant');
         InternalError('Failed to expand "' + OriginalCnst + '" constant');
       Result := AddBackslash(ShellFolder) + WizardGroupValue;
       Result := AddBackslash(ShellFolder) + WizardGroupValue;
@@ -1199,7 +1198,7 @@ begin
     for Common := False to True do
     for Common := False to True do
       for ShellFolderID := Low(ShellFolderID) to High(ShellFolderID) do
       for ShellFolderID := Low(ShellFolderID) to High(ShellFolderID) do
         if Cnst = FolderConsts[Common, ShellFolderID] then begin
         if Cnst = FolderConsts[Common, ShellFolderID] then begin
-          ShellFolder := GetShellFolder(Common, ShellFolderID, False);
+          ShellFolder := GetShellFolder(Common, ShellFolderID);
           if ShellFolder = '' then
           if ShellFolder = '' then
             InternalError(Format('Failed to expand shell folder constant "%s"', [OriginalCnst]));
             InternalError(Format('Failed to expand shell folder constant "%s"', [OriginalCnst]));
           Result := ShellFolder;
           Result := ShellFolder;
@@ -1577,8 +1576,7 @@ begin
     Result := '';
     Result := '';
 end;
 end;
 
 
-function GetShellFolder(const Common: Boolean; const ID: TShellFolderID;
-  ReadOnly: Boolean): String;
+function GetShellFolder(const Common: Boolean; const ID: TShellFolderID): String;
 const
 const
   CSIDL_COMMON_STARTMENU = $0016;
   CSIDL_COMMON_STARTMENU = $0016;
   CSIDL_COMMON_PROGRAMS = $0017;
   CSIDL_COMMON_PROGRAMS = $0017;
@@ -1608,7 +1606,7 @@ var
 begin
 begin
   if not ShellFoldersRead[Common, ID] then begin
   if not ShellFoldersRead[Common, ID] then begin
     if ID = sfUserProgramFiles then begin
     if ID = sfUserProgramFiles then begin
-      ShellFolder := GetShellFolderByGUID(FOLDERID_UserProgramFiles {Windows 7+}, not ReadOnly);
+      ShellFolder := GetShellFolderByGUID(FOLDERID_UserProgramFiles {Windows 7+}, True);
       if ShellFolder = '' then
       if ShellFolder = '' then
         ShellFolder := ExpandConst('{localappdata}\Programs'); { supply default, same as Window 7 and newer }
         ShellFolder := ExpandConst('{localappdata}\Programs'); { supply default, same as Window 7 and newer }
     end else if ID = sfUserCommonFiles then begin
     end else if ID = sfUserCommonFiles then begin
@@ -1618,10 +1616,9 @@ begin
     end else if ID = sfUserSavedGames then
     end else if ID = sfUserSavedGames then
       ShellFolder := GetShellFolderByGUID(FOLDERID_SavedGames {Vista+}, True)
       ShellFolder := GetShellFolderByGUID(FOLDERID_SavedGames {Vista+}, True)
     else
     else
-      ShellFolder := GetShellFolderByCSIDL(FolderIDs[Common, ID], not ReadOnly);
+      ShellFolder := GetShellFolderByCSIDL(FolderIDs[Common, ID], True);
     ShellFolders[Common, ID] := ShellFolder;
     ShellFolders[Common, ID] := ShellFolder;
-    if not ReadOnly or (ShellFolder <> '') then
-      ShellFoldersRead[Common, ID] := True;
+    ShellFoldersRead[Common, ID] := True;
   end;
   end;
   Result := ShellFolders[Common, ID];
   Result := ShellFolders[Common, ID];
 end;
 end;

+ 6 - 6
Projects/SelFolderForm.pas

@@ -61,13 +61,13 @@ begin
     if StartMenu then begin
     if StartMenu then begin
       with Form.FFolderTreeView as TStartMenuFolderTreeView do
       with Form.FFolderTreeView as TStartMenuFolderTreeView do
         if IsNT then
         if IsNT then
-          SetPaths(GetShellFolder(False, sfPrograms, False),
-            GetShellFolder(True, sfPrograms, False),
-            GetShellFolder(False, sfStartup, False),
-            GetShellFolder(True, sfStartup, False))
+          SetPaths(GetShellFolder(False, sfPrograms),
+            GetShellFolder(True, sfPrograms),
+            GetShellFolder(False, sfStartup),
+            GetShellFolder(True, sfStartup))
         else
         else
-          SetPaths(GetShellFolder(False, sfPrograms, False),
-            '', GetShellFolder(False, sfStartup, False), '');
+          SetPaths(GetShellFolder(False, sfPrograms),
+            '', GetShellFolder(False, sfStartup), '');
       TidyUpGroupName(Path);
       TidyUpGroupName(Path);
     end
     end
     else
     else