View Single Post
  #7  
Old 11-12-2019, 13:10
Cesar82's Avatar
Cesar82 Cesar82 is offline
Registered User
 
Join Date: May 2011
Location: Brazil
Posts: 1,074
Thanks: 1,814
Thanked 2,304 Times in 787 Posts
Cesar82 is on a distinguished road
Quote:
Originally Posted by Proxson View Post
Hi ppl,

is there a constant for Users\Username\Saved Games ? I want to delete a folder in Saved Games but to no avail. I can't find that constant on the net.

I tried:

{Userprofile}\Saved Games
{%Userprofile%}\Saved Games
%Userprofile%\Saved Games
{Username}\Saved Games

Edit: The only way is writing down the full path in Setup.ini which is SaveGameFolder3=C:\Users\*****\Saved Games\

Not a very happy solution. I can't believe that the Inno Setup developer didn't include such constant.
There is no native constant in Inno Setup for the "Saved Games" folder.
You can use something like this:
Code:
function UpdateConstant(const S: String): String;
var
  strDocs: String;
  strSaves: String;
begin
  Result := ExpandConstantEx(S, 'savedgames', ExpandConstant('{userdocs}\My Games'));
  if (GetWindowsVersion shr 24 >= 6) and (Result = ExpandConstant('{userdocs}\My Games')) then
  begin
    RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{F42EE2D3-909F-4907-8871-4C22FC0BF756}', 'RelativePath', strDocs);
    RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}', 'RelativePath', strSaves);
    StringChangeEx(Result, '\' + strDocs + '\My Games', '\' + strSaves, True);
  end;
end;
This function also expands the other constants normally:
>> MsgBox(UpdateConstant('{userdocs}'), mbInformation, MB_OK); {expands normally}
>> MsgBox(UpdateConstant('{savedgames}'), mbInformation, MB_OK);

Remembering that CIU already has an UpdateConstant function.
If it is to be used in the CIU script, change the function name such as UpdateConstant2.

Last edited by Cesar82; 11-12-2019 at 15:16.
Reply With Quote
The Following 2 Users Say Thank You to Cesar82 For This Useful Post:
Proxson (11-12-2019), Simorq (11-12-2019)