Get the Virtual Store path?

852 Views Asked by At

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

There are 1 best solutions below

0
Martin Prikryl On BEST ANSWER

I believe there's even no Windows API to retrieve the path to the virtual store, let alone 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.