inno-setup – Inno Setup:运行程序而不显示复选框
我有以下几行:
[Run] Filename: "{app}MyApp.exe"; Flags: postinstall nowait 我希望我的应用程序开始时不显示复选框(这将禁止用户这样做). 有人可以告诉我怎么样吗? 解决方法
我能想到的选择很少.第一个是从脚本的[Code]部分运行应用程序,第二个是禁用[Run]部分条目的复选框,第三个是隐藏RunList.
1.向导完成后如何手动运行应用程序? 我个人更喜欢这种方式,因为它比添加一个复选框并稍后隐藏它更直接.您将删除当前的[Run]部分条目,并在其CurPageID参数等于wpFinished时从 > 因为您尚未使用 function NextButtonClick(CurPageID: Integer): Boolean; var ResultCode: Integer; begin Result := True; if CurPageID = wpFinished then ExecAsOriginalUser(ExpandConstant('{app}MyApp.exe'),'',SW_SHOWNORMAL,ewNoWait,ResultCode); end; 该解决方案的一个缺点是,即使设置请求重新启动,也将执行程序.为了解决缺少确定此请求的可能性,我们可以检查YesRadio是否可见(它是“是,立即重新启动计算机”单选按钮)并选中,这意味着要求用户重新启动计算机并进行确认.以下是考虑重启请求的版本: function NextButtonClick(CurPageID: Integer): Boolean; var ResultCode: Integer; begin Result := True; // if the "Finish" button was clicked and "Yes,restart the computer now" // radio button was either not visible or not selected that time,then... if (CurPageID = wpFinished) and ((not WizardForm.YesRadio.Visible) or (not WizardForm.YesRadio.Checked)) then ExecAsOriginalUser(ExpandConstant('{app}MyApp.exe'),ResultCode); end; 2.如何在最后一页上禁用安装后复选框? 另一个选项是禁用复选框.用户将看到应用程序将被执行,但无法对其执行任何操作(当然,除了从任务管理器中删除设置).这次你将保留[Run]部分条目,但是从[Code]部分修改RunList: [Setup] AppName=My Program AppVersion=1.5 DefaultDirName=My Program [Files] Source: "MyApp.exe"; DestDir: "{app}" [Run] Filename: "{app}MyApp.exe"; Flags: postinstall nowait [Code] procedure CurPageChanged(CurPageID: Integer); begin // you must do this as late as possible,because the RunList is being modified // after installation; so this will check if there's at least one item in the // RunList and then set to the first item (indexing starts at 0) Enabled state // to False if (CurPageID = wpFinished) and (WizardForm.RunList.Items.Count > 0) then WizardForm.RunList.ItemEnabled[0] := False; end; 3.如何完全隐藏RunList? 与第二个选项相反,这将按照您的要求执行.它将隐藏复选框,或者更确切地说,它将隐藏整个RunList,因此如果在[Run]部分中指定了 [Setup] AppName=My Program AppVersion=1.5 DefaultDirName=My Program [Files] Source: "MyApp.exe"; DestDir: "{app}" [Run] Filename: "{app}MyApp.exe"; Flags: postinstall nowait [Code] procedure CurPageChanged(CurPageID: Integer); begin if CurPageID = wpFinished then WizardForm.RunList.Visible := False; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |