2016-05-03 38 views
1

我想製作Steam備份安裝程序。但是,Steam允許用戶製作多個庫文件夾,這使安裝變得困難。從文件中讀取字符串並給出選擇安裝的選項

我想執行一些任務。

  1. 安裝程序應從註冊表中識別路徑以確定安裝Steam的位置。 "BaseInstallFolder_3""BaseInstallFolder_1"
  2. 所得從註冊表打開文件

    X:\Steam\config\config.vdf 
    

    路徑和讀值,"BaseInstallFolder_2",等

    config.vdf

    "NoSavePersonalInfo"  "0" 
    "MaxServerBrowserPingsPerMin"  "0" 
    "DownloadThrottleKbps"  "0" 
    "AllowDownloadsDuringGameplay"  "0" 
    "StreamingThrottleEnabled"  "1" 
    "AutoUpdateWindowStart"  "-1" 
    "AutoUpdateWindowEnd"  "-1" 
    "LastConfigstoreUploadTime"  "1461497849" 
    "BaseInstallFolder_1"  "E:\\Steam_GAMES" 
    
  3. 所得到的路徑或文件config.vdf的路徑在DirEdit

  4. 帶來如果用戶有多個路徑,以在不同的位置的文件夾然後給選項通過DirTreeView或單選按鈕進行選擇。

    究竟應該如何樣子:

    enter image description here


我知道如何識別蒸汽路徑

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

但很難執行其他任務

預先感謝您的幫助。

+0

這些是兩個單獨的問題:解析文件和執行預定義的路徑的選擇。分別詢問他們。 –

回答

0

爲了解析config.vdf文件:

代碼可以是這樣的:

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;