正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- [Setup]
- AppName=My Program
- AppVersion=1.5
- DefaultDirName={pf}\My Program
- DirExistsWarning=no
- [Files]
- ;安装新的文件,备份旧的文件
- Source: "myfile\*"; DestDir: "{app}"; Flags: recursesubdirs; BeforeInstall: MakeBackUp
- [Code]
- procedure MakeBackUp;
- var
- dn, fn, rp, cp: string;
- ResultCode: Integer;
- begin
- dn:= ExpandConstant(ExtractFileDir(CurrentFileName));
- fn:= ExtractFileName(CurrentFileName);
- cp:= ExpandConstant('{app}');
- rp:= dn;
- if FileExists(dn + '\' + fn) then
- begin
- if not DirExists(cp + '\backup') then
- CreateDir(cp + '\backup');
- if pos(cp, dn) = 1 then
- delete(rp, 1, length(cp));
- if not DirExists(cp + '\backup' + rp) then
- Exec(ExpandConstant('{cmd}'), '/c mkdir "' + cp + '\backup' + rp + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
- FileCopy(dn + '\' + fn, cp + '\backup' + rp + '\' + fn, false);
- end;
- end;
- procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep); //卸载成功后看情况恢复备份的文件
- var
- ResultCode: Integer;
- begin
- if CurUninstallStep = usDone then
- begin
- if Exec('xcopy.exe', ExpandConstant('"{app}\backup\*.*" "{app}" /S /Y /H'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
- DelTree(ExpandConstant('{app}\backup'), True, True, True);
- end;
- end;
复制代码
|