1

I want to make Steam backups installer. However, Steam allow to user make multiple library folders which makes installation difficult.

There are a few tasks that I want to perform.

  1. Installer should identify path from registry to identify where Steam is installed.
  2. The resulting path from registry open file

    X:\Steam\config\config.vdf
    

    and read value of "BaseInstallFolder_1", "BaseInstallFolder_2", "BaseInstallFolder_3" and etc.

    Example of config.vdf:

    "NoSavePersonalInfo"        "0"
    "MaxServerBrowserPingsPerMin"       "0"
    "DownloadThrottleKbps"      "0"
    "AllowDownloadsDuringGameplay"      "0"
    "StreamingThrottleEnabled"      "1"
    "AutoUpdateWindowStart"     "-1"
    "AutoUpdateWindowEnd"       "-1"
    "LastConfigstoreUploadTime"     "1461497849"
    "BaseInstallFolder_1"       "E:\\Steam_GAMES"
    
  3. The resulting path or paths of the file config.vdf bring in DirEdit

  4. If user have multiple paths to the folder in different locations then give option select through DirTreeView or Radiobuttons.

    How it should look like:

    enter image description here


I know how to identify Steam path

WizardForm.DirEdit.Text := ExpandConstant('{reg:HKLM\SOFTWARE\Valve\Steam,InstallPath|{pf}\Steam}')+ '\steamapps\common\gamename';

But it is difficult to perform other tasks

Thanks in advance for your help.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
nuru
  • 11
  • 2

1 Answers1

2

To parse the config.vdf file:

The code may be like:

function ParseSteamConfig(FileName: string; var Paths: TArrayOfString): Boolean;
var
  Lines: TArrayOfString;
  I: Integer;
  Line: string;
  P: Integer;
  Key: string;
  Value: string;
  Count: Integer;
begin
  Result := LoadStringsFromFile(FileName, Lines);

  Count := 0;

  for I := 0 to GetArrayLength(Lines) - 1 do
  begin
    Line := Trim(Lines[I]);
    if Copy(Line, 1, 1) = '"' then
    begin
      Delete(Line, 1, 1);
      P := Pos('"', Line);
      if P > 0 then
      begin
        Key := Trim(Copy(Line, 1, P - 1));
        Delete(Line, 1, P);
        Line := Trim(Line);
        Log(Format('Found key "%s"', [Key]));

        if (CompareText(
              Copy(Key, 1, Length(BaseInstallFolderKeyPrefix)),
              BaseInstallFolderKeyPrefix) = 0) and
           (Line[1] = '"') then
        begin
          Log(Format('Found base install folder key "%s"', [Key]));
          Delete(Line, 1, 1);
          P := Pos('"', Line);
          if P > 0 then
          begin
            Value := Trim(Copy(Line, 1, P - 1));
            StringChange(Value, '\\', '\');
            Log(Format('Found base install folder "%s"', [Value]));
            Inc(Count);
            SetArrayLength(Paths, Count);
            Paths[Count - 1] := Value;
          end;
        end;
      end;
    end;
  end;
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992