关于Innosetup 打包安装时读取上一次安装路径的问题网上也有挺多的文章,基本的思路就是安装时向注册表写安装路径,下次安装时从注册表读取上一次安装路径,方法如下:
[Registry]
Root:HKLM;Subkey:"Software\Myprogrom";Flags:uninsdeletekeyifempty
Root:HKLM;Subkey:"Software\Myprogrom";ValueType:string;ValueName:"InstallPath";ValueData:"{app}";Flags:uninsdeletekey
【code】
function GetDirName(Value: string): string;
var
InstallPath: string;
begin
Result := ExpandConstant('{pf}\Myprogrom');//默认
if RegQueryStringValue(HKLM, 'SOFTWARE\Myprogrom', '', InstallPath) then //注册表如果有 则读取
Result := InstallPath;
end;
但是,有几点需要注意: