소스 검색

Added new constant: {usersavedgames}.

Martijn Laan 5 년 전
부모
커밋
63244049e0
4개의 변경된 파일22개의 추가작업 그리고 8개의 파일을 삭제
  1. 6 0
      ISHelp/isetup.xml
  2. 2 2
      Projects/Compile.pas
  3. 13 6
      Projects/Main.pas
  4. 1 0
      whatsnew.htm

+ 6 - 0
ISHelp/isetup.xml

@@ -388,6 +388,7 @@ This " contains " embedded " quotes
 <keyword value="{username}" anchor="username" />
 <keyword value="{userpf}" anchor="userpf" />
 <keyword value="{userprograms}" anchor="userprograms" />
+<keyword value="{usersavedgames}" anchor="usersavedgames" />
 <keyword value="{usersendto}" anchor="usersendto" />
 <keyword value="{sendto}" anchor="usersendto" />
 <keyword value="{userstartmenu}" anchor="userstartmenu" />
@@ -596,6 +597,11 @@ For example: If you used <tt>{src}\MYPROG.EXE</tt> on an entry and the user is i
 <p>The path to the Programs folder on the Start Menu.</p>
 </dd>
 
+<dt><b><a name="usersavedgames">{usersavedgames}</a></b></dt>
+<dd>
+<p>The path to the current user's Saved Games directory.</p>
+</dd>
+
 <dt><b><a name="usersendto">{usersendto}</a></b></dt>
 <dd>
 <p>The path to the current user's Send To folder. (There is no common Send To folder.)</p>

+ 2 - 2
Projects/Compile.pas

@@ -2887,8 +2887,8 @@ function TSetupCompiler.CheckConst(const S: String; const MinVersion: TSetupVers
   end;
 
 const
-  UserConsts: array[0..2] of String = (
-    'userpf', 'usercf', 'username');
+  UserConsts: array[0..3] of String = (
+    'userpf', 'usercf', 'usersavedgames', 'username');
   Consts: array[0..42] of String = (
     'src', 'srcexe', 'tmp', 'app', 'win', 'sys', 'sd', 'groupname', 'fonts', 'hwnd',
     'commonpf', 'commonpf32', 'commonpf64', 'commoncf', 'commoncf32', 'commoncf64',

+ 13 - 6
Projects/Main.pas

@@ -123,7 +123,7 @@ var
   { 'Constants' }
   SourceDir, TempInstallDir, WinDir, WinSystemDir, WinSysWow64Dir, WinSysNativeDir, SystemDrive,
     ProgramFiles32Dir, CommonFiles32Dir, ProgramFiles64Dir, CommonFiles64Dir,
-    ProgramFilesUserDir, CommonFilesUserDir, CmdFilename, SysUserInfoName,
+    ProgramFilesUserDir, CommonFilesUserDir, SavedGamesUserDir, CmdFilename, SysUserInfoName,
     SysUserInfoOrg, UninstallExeFilename: String;
 
   { Uninstall 'constants' }
@@ -1111,6 +1111,7 @@ begin
     else
       InternalError('Cannot expand "' + OriginalCnst + '" constant on this version of Windows');
   end
+  else if Cnst = 'usersavedgames' then Result := SavedGamesUserDir
   else if Cnst = 'dao' then Result := ExpandConst('{cf}\Microsoft Shared\DAO')
   else if Cnst = 'cmd' then Result := CmdFilename
   else if Cnst = 'computername' then Result := GetComputerNameString
@@ -1335,6 +1336,7 @@ procedure InitMainNonSHFolderConsts;
 const
   FOLDERID_UserProgramFiles: TGUID = (D1:$5CD7AEE2; D2:$2219; D3:$4A67; D4:($B8,$5D,$6C,$9C,$E1,$56,$60,$CB));
   FOLDERID_UserProgramFilesCommon: TGUID = (D1:$BCBD3057; D2:$CA5C; D3:$4622; D4:($B4,$2D,$BC,$56,$DB,$0A,$E5,$16));
+  FOLDERID_SavedGames: TGUID = (D1:$4C5C32FF; D2:$BB9D; D3:$43B0; D4:($B5,$B4,$2D,$72,$E5,$4E,$AA,$A4));
   KF_FLAG_CREATE = $00008000;
 var
   Path: PWideChar;
@@ -1375,24 +1377,29 @@ begin
       InternalError('Failed to get path of 64-bit Common Files directory');
   end;
 
-  { Get per-user Program Files and Common Files dirs. Requires Windows 7 or
-    later but trying it on Vista too in case some update adds support for the
-    folders later (like we saw with CSIDLs in the old days). }
+  { Get dirs which have no CSIDL equivalent and cannot be retrieved using SHGetFolderPath. }
   if Assigned(SHGetKnownFolderPathFunc) and (WindowsVersion shr 16 >= $0600) then begin
-    if SHGetKnownFolderPathFunc(FOLDERID_UserProgramFiles, KF_FLAG_CREATE, 0, Path) = S_OK then begin
+    if SHGetKnownFolderPathFunc(FOLDERID_UserProgramFiles {Windows 7+}, KF_FLAG_CREATE, 0, Path) = S_OK then begin
       try
         ProgramFilesUserDir := WideCharToString(Path);
       finally
         CoTaskMemFree(Path);
       end;
     end;
-    if SHGetKnownFolderPathFunc(FOLDERID_UserProgramFilesCommon, KF_FLAG_CREATE, 0, Path) = S_OK then begin
+    if SHGetKnownFolderPathFunc(FOLDERID_UserProgramFilesCommon {Windows 7+}, KF_FLAG_CREATE, 0, Path) = S_OK then begin
       try
         CommonFilesUserDir := WideCharToString(Path);
       finally
         CoTaskMemFree(Path);
       end;
     end;
+    if SHGetKnownFolderPathFunc(FOLDERID_SavedGames {Vista+}, KF_FLAG_CREATE, 0, Path) = S_OK then begin
+      try
+        SavedGamesUserDir := WideCharToString(Path);
+      finally
+        CoTaskMemFree(Path);
+      end;
+    end;
   end;
   
   { Get path of command interpreter }

+ 1 - 0
whatsnew.htm

@@ -28,6 +28,7 @@ For conditions of distribution and use, see <a href="http://www.jrsoftware.org/f
 
 <p><a name="6.0.4"></a><span class="ver">6.0.4-dev </span><span class="date">(?)</span></p>
 <ul>
+  <li>Added new constant: <tt>{usersavedgames}</tt>.</li>
   <li>[Setup] section directives <tt>LicenseFile</tt>, <tt>InfoBeforeFile</tt> and <tt>InfoAfterFile</tt> now support objects such as images in .rtf (rich text) files.</li>
   <li><i>Fix:</i> Event attributes for uninstall event functions now actually work.</li>
   <li>Minor tweaks.</li>