我想制作Steam备份安装程序。但是,Steam允许用户创建多个库文件夹,这使得安装变得困难。
我想要执行一些任务。
从注册表打开文件
生成的路径X:\Steam\config\config.vdf
并读取"BaseInstallFolder_1"
,"BaseInstallFolder_2"
,"BaseInstallFolder_3"
等的值。
config.vdf
的示例:
"NoSavePersonalInfo" "0"
"MaxServerBrowserPingsPerMin" "0"
"DownloadThrottleKbps" "0"
"AllowDownloadsDuringGameplay" "0"
"StreamingThrottleEnabled" "1"
"AutoUpdateWindowStart" "-1"
"AutoUpdateWindowEnd" "-1"
"LastConfigstoreUploadTime" "1461497849"
"BaseInstallFolder_1" "E:\\Steam_GAMES"
文件config.vdf
生成的路径引入DirEdit
如果用户在不同位置有多个指向该文件夹的路径,则通过DirTreeView或Radiobuttons选择选项。
它应该如何:
我知道如何识别Steam路径
WizardForm.DirEdit.Text := ExpandConstant('{reg:HKLM\SOFTWARE\Valve\Steam,InstallPath|{pf}\Steam}')+ '\steamapps\common\gamename';
但是很难执行其他任务
提前感谢您的帮助。
答案 0 :(得分:1)
解析config.vdf
文件:
LoadStringsFromFile
加载文件。Copy
,Pos
,Delete
,CompareText
来解析它。array of string
(或预定义的TArrayOfString
)。要分配数组,请使用SetArrayLength
。代码可能如下:
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;