[英]Ending the setup when all components have been installed in Inno Setup
當所有組件都已安裝時,我試圖讓我的安裝程序停止。
安裝示例:
wpFinished
頁面或停止並顯示“所有組件都已安裝”的消息。我在這里和其他網站上做了一些研究,我做了以下事情:
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm := False;
end;
procedure InitializeWizard;
var
ItemIndex: Integer;
InstallEn: String;
InstallFr: String;
InstallDe: String;
CompDescEnIndex: Integer;
CompDescFrIndex: Integer;
CompDescDeIndex: Integer;
Check: Integer;
begin
# This part is to make not selectable component already install
if RegQueryStringValue(HKLM, 'Software\COMPANY\{#RegProduct}\{#RegCurVer}', 'Install-ENG', InstallEn) then
if ((InstallEn = 'International Pack' )
or (InstallEn = 'Pack International')
or (InstallEn = 'International Paket'))
then
ItemIndex := WizardForm.ComponentsList.Items.IndexOf(CustomMessage('CompDescEn'));
WizardForm.ComponentsList.ItemEnabled[ItemIndex] := False;
if RegQueryStringValue(HKLM, 'Software\COMPANY\{#RegProduct}\{#RegCurVer}', 'Install-FRA', InstallFr) then
if ((InstallFr = 'French Pack')
or (InstallFr = 'Pack France')
or (InstallFr = 'Franzosisch Paket'))
then
ItemIndex := WizardForm.ComponentsList.Items.IndexOf(CustomMessage('CompDescFr'));
WizardForm.ComponentsList.ItemEnabled[ItemIndex] := False;
if RegQueryStringValue(HKLM, 'Software\COMPANY\{#RegProduct}\{#RegCurVer}', 'Install-DEU', InstallDe) then
if ((InstallDe = 'German Pack')
or (InstallDe = 'Pack Allemand')
or (InstallDe = 'Deutsches Paket'))
then
ItemIndex := WizardForm.ComponentsList.Items.IndexOf(CustomMessage('CompDescDe'));
WizardForm.ComponentsList.ItemEnabled[ItemIndex] := False;
# After I try to say if all component are install, close the wizard.
CompDescEnIndex := WizardForm.ComponentsList.Items.IndexOf(CustomMessage('CompDescEn'));
CompDescFrIndex := WizardForm.ComponentsList.Items.IndexOf(CustomMessage('CompDescFr'));
CompDescDeIndex := WizardForm.ComponentsList.Items.IndexOf(CustomMessage('CompDescDe'));
if not WizardForm.ComponentsList.ItemEnabled[CompDescEnIndex]
and not WizardForm.ComponentsList.ItemEnabled[CompDescFrIndex]
and not WizardForm.ComponentsList.ItemEnabled[CompDescDeIndex]
then
Check := 1;
if (Check <> 0) then
WizardForm.Close;
end;
注意:代碼可能不是很干凈,我從Code
部分的 Pascal + Inno Setup 開始。
如果我的所有組件都已安裝(並且不可選擇),我希望向導停止而不是繼續...
我找不到直接進入wpFinished
頁面的解決方案......有沒有辦法做到這一點?
如果由於WizardForm.Close;
安裝了所有組件,我該如何停止向導WizardForm.Close;
在我的情況下似乎不起作用?
感謝您的幫助。
您不能跳到wpFinished
頁面,因為 Inno Setup 不允許您跳過wpReady
頁面以避免創建全自動安裝程序(可能會被濫用)。
你可以創建一個自定義的“完成”頁面:
procedure AllInstalledPageActivate(Sender: TWizardPage);
begin
{ Change the "Next" button to "Finish" on our custom page }
WizardForm.NextButton.Caption := SetupMessage(msgButtonFinish);
{ Hide the "Cancel" button }
WizardForm.CancelButton.Visible := False;
end;
procedure ExitProcess(uExitCode: UINT);
external 'ExitProcess@kernel32.dll stdcall';
function AllInstalledPageNextButtonClick(Sender: TWizardPage): Boolean;
begin
{ Abort the installer when the "Finish" button is clicked on our custom page }
ExitProcess(0);
Result := True; { shut up the compiler warning }
end;
procedure InitializeWizard();
var
Caption: TLabel;
AllInstalledPage: TWizardPage;
begin
...
{ If everything is installed already ... }
if IsEverythingInstalled then
begin
{ ... create a custom "everything is installed" page }
AllInstalledPage :=
CreateCustomPage(
wpWelcome, 'All components are installed already',
'There''s nothing to install.');
AllInstalledPage.OnActivate := @AllInstalledPageActivate;
AllInstalledPage.OnNextButtonClick := @AllInstalledPageNextButtonClick;
Caption := TLabel.Create(AllInstalledPage);
Caption.Caption :=
'Everything is installed already. Click Finish to close the installer.';
Caption.Width := AllInstalledPage.SurfaceWidth;
Caption.Parent := AllInstalledPage.Surface;
end;
end;
更簡單的解決方案是使用簡單的消息框。
Wizard.Close
將關閉安裝程序,無論如何它不會轉到“已完成”頁面。 如果您真的想中止安裝程序,請從InitializeSetup
返回False
(您需要將一些代碼移動到InitializeSetup
)。
或者使用ExitProcess
函數,就像我的例子一樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.