如果您想为用户提供一些反馈,您可以尝试类似的方法。首先,您的更新应该与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;