Get the Virtual Store path?

喜夏-厌秋 提交于 2019-12-08 10:44:29

问题


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:


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.



来源:https://stackoverflow.com/questions/31206772/what-is-the-write-constant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!