Inno Setup:升级时禁用组件页面 [英] Inno Setup: Disable components page on upgrade
问题描述
是否有一种方法可以禁用组件页面"以进行升级?我想启用我的软件的升级,但是我不想让用户在升级时更改组件的选择. 相反,安装程序会从首次安装中升级所有现有组件.
Is there a way to disable the Components Page for Upgrades? I would like to enable upgrades of my software but I don't want to allow the users to change the selection of components in case of an upgrade. Instead the installer you upgrade all existing components from the first installation.
我担心如果用户在升级过程中选择的组件更少,那些丢失的组件会像旧版本一样保持安装状态,从而使您一团糟.
I am worried that it the user selects less components during the upgrade those missing components will stay installed as the old version and you get a mess.
我在脚本中添加了以下内容:
I added the following to my script:
[Setup]
DisableDirPage=auto
DisableProgramGroupPage=auto
DirExistsWarning=auto
我只需要一种方法来禁用组件页面,并使用先前安装(完全安装)的选择进行升级.有可能吗?
I just need a way to disable the components page and use the selection of the previous install (full install) for the upgrade. Is that possible?
我找到了一个相关的指令:
I have found a related directive:
[Setup]
UsePreviousTasks=true
UsePreviousTasks
正在从注册表中读取现有部分,这很好.现在,我需要找到一种隐藏选择窗口的方法.
UsePreviousTasks
is reading the existing section out of the registry which is good. Now I need to find a way to hide the selection window.
谢谢,
沃尔夫冈
Thanks,
Wolfgang
推荐答案
要向用户隐藏页面,请使用 ShouldSkipPage
事件方法.如果以这种方法返回True,则该页面将不会显示给用户.如果为False,则该页面将照常显示.这是如何检查安装是否为升级的示例,如果是,请跳过选择组件"向导页面:
To hide a page from user use the ShouldSkipPage
event method. If you return True in this method, the page won't be shown to user. If False, the page will be displayed as usually. Here 's an example of how to check if the installation is an upgrade and if so, skip the Select Components wizard page:
[Setup]
AppId=B75E4823-1BC9-4AC6-A645-94027A16F5A5
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
; here is the place for your [Components] section and the rest of your script
[Code]
const
UninstallKey = 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#SetupSetting("AppId")}_is1';
function IsUpgrade: Boolean;
var
Value: string;
begin
Result := (RegQueryStringValue(HKLM, UninstallKey, 'UninstallString', Value) or
RegQueryStringValue(HKCU, UninstallKey, 'UninstallString', Value)) and (Value <> '');
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := (PageID = wpSelectComponents) and IsUpgrade;
end;
您提到的另一个选项可能是禁用页面的所有控件.下一个脚本作为上一个脚本显示如何检查安装是否为升级,如果是,则禁用选择组件"向导页面上的所有控件:
Another option you mentioned might be to disable all the controls of the page. The next script shows as the previous one how to check if the installation is an upgrade and if so, disables all the controls on the Select Components wizard page:
[Setup]
AppId=B75E4823-1BC9-4AC6-A645-94027A16F5A5
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
; here is the place for your [Components] section and the rest of your script
[Code]
const
UninstallKey = 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#SetupSetting("AppId")}_is1';
function IsUpgrade: Boolean;
var
Value: string;
begin
Result := (RegQueryStringValue(HKLM, UninstallKey, 'UninstallString', Value) or
RegQueryStringValue(HKCU, UninstallKey, 'UninstallString', Value)) and (Value <> '');
end;
procedure DisablePageControls(Page: TNewNotebookPage);
var
I: Integer;
begin
Page.Enabled := False;
for I := 0 to Page.ControlCount - 1 do
Page.Controls[I].Enabled := False;
end;
procedure InitializeWizard;
begin
if IsUpgrade then
DisablePageControls(WizardForm.SelectComponentsPage);
end;
这篇关于Inno Setup:升级时禁用组件页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!