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?
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.