View Single Post
  #142  
Old 02-11-2021, 09:12
Cesar82's Avatar
Cesar82 Cesar82 is offline
Registered User
 
Join Date: May 2011
Location: Brazil
Posts: 777
Thanks: 1,290
Thanked 1,643 Times in 559 Posts
Cesar82 is on a distinguished road
Quote:
Originally Posted by giruthanders View Post
Hello, I would like to ask how I could make the setup remember the folder I install my games in, like FitGirl's?

The default is C:\Program Files, but for example I change it to D:\Games. I want the installer to remember so that the next game I install, it will default to that directory instead of going back to C.
FitGirl installers look for the next drive other than the drive the system is installed on and always install the game in a "Games" subfolder.
It doesn't memorize your last choice, it always installs in a "Games" folder and on the same drive.
Even if you choose "E:\My Games", assuming the system is installed on the "C:" drive in the next install it will suggest "D:\Games" as in the first install (Correct me if I'm wrong).

If you want similar behavior change the line in the [Setup] section of the script.
Code:
from:
DefaultDirName={#DefaultDir}\{#GameName}

to:
DefaultDirName={code:NoSD}\Games\{#GameName}
Then paste this code below into the [ Code] section of the script.
Code:
const
  DRIVE_FIXED = 3;

function GetLogicalDriveStrings(nLenDrives: DWORD; lpDrives: String): DWORD;
  external '[email protected] stdcall delayload';

function GetDriveType(lpDisk: String): DWORD;
  external '[email protected] stdcall delayload';

function NoSD(Param: String): String;
var
  Drive: String;
  Buffer: String;
begin
  SetLength(Buffer, 255);
  SetLength(Buffer, GetLogicalDriveStrings(254, Buffer));
  Result := ExpandConstant('{sd}');
  while Pos(#0, Buffer) > 0 do
  begin
    Drive := Copy(Buffer, 1, Pos(#0, Buffer) - 1);
    if (GetDriveType(Drive) = DRIVE_FIXED) and (CompareText(Drive, ExpandConstant('{sd}\')) <> 0) then
    begin
      Result := RemoveBackslash(Drive);
      Break;
    end;
    Delete(Buffer, 1, Pos(#0, Buffer));
  end;
end;
I hope that's what you need.

Last edited by Cesar82; 02-11-2021 at 09:25.
Reply With Quote
The Following 2 Users Say Thank You to Cesar82 For This Useful Post:
Gehrman (03-11-2021), giruthanders (05-11-2021)