如果你想对用户有一些反馈,你可以尝试类似的东西。 首先,您的更新应该与您的主应用程序具有相同的AppId
名称。 然后您可以设置一些检查,即显示消息以通知用户有关状态。
#define MyAppVersion "1.2.2.7570"
#define MyAppName "MyApp Update"
[Setup]
AppId=MyApp
AppName={#MyAppName}
AppVersion={#MyAppVersion}
DefaultDirName={reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MyApp_is1,InstallLocation}
DisableDirPage=True
[CustomMessages]
MyAppOld=The Setup detected application version
MyAppRequired=The installation of {#MyAppName} requires MyApp to be installed.%nInstall MyApp before installing this update.%n%n
MyAppTerminated=The setup of update will be terminated.
[Code]
var
InstallLocation: String;
function GetInstallString(): String;
var
InstPath: String;
InstallString: String;
begin
InstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp_is1');
InstallString := '';
if not RegQueryStringValue(HKLM, InstPath, 'InstallLocation', InstallString) then
RegQueryStringValue(HKCU, InstPath, 'InstallLocation', InstallString);
Result := InstallString;
InstallLocation := InstallString;
end;
function InitializeSetup: Boolean;
var
V: Integer;
sUnInstallString: String;
Version: String;
begin
if RegValueExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp_is1', 'UninstallString') then begin
RegQueryStringValue(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp_is1', 'DisplayVersion', Version);
if Version =< ExpandConstant('{#MyAppVersion}') then begin
Result := True;
GetInstallString();
end
else begin
MsgBox(ExpandConstant('{cm:MyAppOld}'+Version+'.'+#13#10#13#10+'{cm:MyAppRequired}'+'{cm:MyAppTerminated}'), mbInformation, MB_OK);
Result := False;
end;
end
else begin
MsgBox(ExpandConstant('{cm:MyAppRequired}'+'{cm:MyAppTerminated}'), mbInformation, MB_OK);
Result := False;
end;
end;
其实,如果你使用脚本向导来创建自己的脚本,然后应用程序文件的默认是添加'ignoreversion'标志,在这种情况下,降级实际上将降级的所有文件。为了确认用户确实想要这么做,添加一条警告消息可能是一个好主意,但是否则应该可以正常工作 - 假设您的应用程序本身可以应付降级(例如,数据兼容性问题)。如果没有,那么你应该添加一个错误,而不是一个警告。 – Miral 2013-03-27 19:51:00
@病毒我没有注意到。感谢您的高举。 – Deanna 2013-03-28 09:30:35
用于检查'InitializeSetup'的示例逻辑将非常棒...我假设已经有一些定义已经出现在inno中... – Assimilater 2017-06-19 19:08:38