Get the Virtual Store path?

2019-06-10 11:32发布

I'm installing an application and want to set values for an ini file. Unfortunately, our main application is still built on a platform that gets redirected to the virtual store. Is there a way to get Inno Setup to store the ini file in the virtual store directly?

1条回答
趁早两清
2楼-- · 2019-06-10 12:08

I believe there's even no Windows API to retrieve the path to the virtual store, let only possibility to retrieve it reliably using Inno Setup.

But you can guess it to be {localappdata}\VirtualStore\path.

[Files]
Source: "MyProg.ini"; DestDir: "{code:GetVirtualStore|{app}}"

[Code]

function GetVirtualStore(Path: string): string;
var
  Drive: string;
begin
  Result := Path;
  Drive := ExtractFileDrive(Path);
  if CompareText(Drive, Copy(Path, 1, Length(Drive))) = 0 then
  begin
    Result := Copy(Result, Length(Drive) + 1, Length(Result) - Length(Drive));
    Result := ExpandConstant('{localappdata}\VirtualStore') + Result;
  end;
end;

You should probably also check that the path is on a system drive.

查看更多
登录 后发表回答