2014-02-20 38 views
3

我們將應用程序切換到.Net4,但我們仍然在Windows XP SP2上擁有客戶。所以我需要在設置中進行額外檢查。Inno - 在其他任何東西之前的自定義頁面

使在安裝開始彈出消息扔掉XP SP2的用戶是很容易的:

function InitializeSetup(): Boolean; 
var 
    Version: TWindowsVersion; 
begin 
    if IsModuleLoaded('monalbumphoto.exe') then begin 
    MsgBox(ExpandConstant('{cm:PleaseClose}'), mbError, MB_OK); 
    Result := false; 
    Abort; 
    end else begin 
    // check Windows version (to display a better error message for XP SP2 users) 
    GetWindowsVersionEx(Version); 
    if (Version.Major = 5) and (Version.Minor = 1) and (Version.ServicePackMajor < 3) then begin 
     MsgBox(ExpandConstant('{cm:WrongVersion}'), mbError, MB_OK); 
     Result := false; 
     Abort; 
    end else begin 
     Result := true; 
    end; 
    end; 
end; 

但現在,需求發生了變化。我需要顯示(類型很長)的消息,解釋用戶必須升級到SP3,或者下載我們的應用程序的舊版本,並附上鍊接。

簡單的方法是將消息框更改爲使用「YESNO」按鈕(如在此問題How to show a hyperlink in Inno Setup?中)來自動下載設置。但我想進一步。

我想顯示一個自定義嚮導頁面的解釋和嵌入式鏈接。另一個問題(Inno Setup custom page)顯示瞭如何去做,但看起來我只能在特定頁面後面創建頁面,而不是在創建任何頁面之前。

那麼,是否可以在任何其他頁面顯示自定義嚮導頁面,取消整個安裝?

謝謝!

+1

如果該頁面是安裝限位器?如果是這樣,那麼我不會使用嚮導頁面。它可能會誤導用戶,而不是談論爲了隱藏下一個按鈕而必須進行的修改。有一個選項可以製作一個常規表格(窗口),其中可以包含任何您能想到的內容。 – TLama

+1

謝謝,這會做得很好(我沒有看到這個選項...)!不幸的是,我不能將你的評論標記爲「答案」。 – thomasb

+0

不客氣! – TLama

回答

1

感謝@TLama,我現在有這個,這似乎是偉大的工作:

// http://stackoverflow.com/questions/5461674/ 
function GetSystemMetrics (nIndex: Integer): Integer; 
    external '[email protected] stdcall setuponly'; 

Const 
    SM_CXSCREEN = 0; // The enum-value for getting the width of the cient area for a full-screen window on the primary display monitor, in pixels. 
    SM_CYSCREEN = 1; // The enum-value for getting the height of the client area for a full-screen window on the primary display monitor, in pixels. 

// Download the legacy version of the software 
procedure DownloadLegacyVersion(Sender : TObject); 
var 
    ErrorCode: Integer; 
begin 
    ShellExec('open', 'http://download.monalbumphoto.fr/monAlbumPhoto_XPSP2.exe', '', '', SW_SHOW, ewNoWait, ErrorCode); 
end; 

// Download the legacy version of the software 
procedure OpenWindowsUpdate(Sender : TObject); 
var 
    ErrorCode: Integer; 
begin 
    ShellExec('open', 'http://update.microsoft.com/', '', '', SW_SHOW, ewNoWait, ErrorCode); 
end; 

// creates a form specifying that the user must upgrade to SP3 or download a legacy version 
procedure WindowsUpgradeNeeded(); 
var 
    Form: TSetupForm; 
    StaticText: TNewStaticText; 
    LinkButton, UpdateButton, OKButton: TNewButton; 
begin 
    Form := CreateCustomForm(); 
    try 
    Form.ClientWidth := ScaleX(500); 
    Form.ClientHeight := ScaleY(200); 
    Form.Caption := ExpandConstant('{cm:WrongVersionTitle}'); 
    Form.BorderStyle := bsDialog; 
    Form.Center(); 

    StaticText := TNewStaticText.Create(Form); 
    StaticText.Top := ScaleY(10); 
    StaticText.Left := ScaleX(10); 
    StaticText.Caption := ExpandConstant('{cm:WrongVersion}'); 
    StaticText.AutoSize := True; 
    StaticText.Parent := Form; 

    LinkButton := TNewButton.Create(Form); 
    LinkButton.Parent := Form; 
    LinkButton.Width := ScaleX(200); 
    LinkButton.Height := ScaleY(30); 
    LinkButton.Left := Round(Form.ClientWidth/2) - Round(LinkButton.Width/2); 
    LinkButton.Top := ScaleY(StaticText.Top + StaticText.Height + 10); 
    LinkButton.Caption := ExpandConstant('{cm:WrongVersionDL}'); 
    LinkButton.OnClick := @DownloadLegacyVersion; 
    LinkButton.Default := True; 

    UpdateButton := TNewButton.Create(Form); 
    UpdateButton.Parent := Form; 
    UpdateButton.Width := ScaleX(200); 
    UpdateButton.Height := ScaleY(30); 
    UpdateButton.Left := Round(Form.ClientWidth/2) - Round(LinkButton.Width/2); 
    UpdateButton.Top := ScaleY(StaticText.Top + StaticText.Height + 10 + LinkButton.Height + 10); 
    UpdateButton.Caption := ExpandConstant('{cm:WrongVersionWU}'); 
    UpdateButton.OnClick := @OpenWindowsUpdate; 
    UpdateButton.Default := True; 

    OKButton := TNewButton.Create(Form); 
    OKButton.Parent := Form; 
    OKButton.Width := ScaleX(75); 
    OKButton.Height := ScaleY(23); 
    OKButton.Left := Round(Form.ClientWidth/2) - Round(OKButton.Width/2); 
    OKButton.Top := Form.ClientHeight - ScaleY(23 + 10); 
    OKButton.Caption := 'OK'; 
    OKButton.ModalResult := mrOk; 
    OKButton.Default := False; 

    Form.ActiveControl := LinkButton; 

    if Form.ShowModal() = mrOk then 
     MsgBox('You clicked OK.', mbInformation, MB_OK); 
    finally 
    Form.Free(); 
    end; 
end; 

// checks if map already running, and the minimum Windows version 
function InitializeSetup(): Boolean; 
var 
    Version: TWindowsVersion; 
begin 
    // check Windows version (to display a better error message for XP SP2 users) 
    GetWindowsVersionEx(Version); 
    if (Version.Major = 5) and (Version.Minor = 1) and (Version.ServicePackMajor < 3) then begin 
     WindowsUpgradeNeeded(); 
     Result := false; 
    end else begin 
     Result := true; 
    end; 
end; 
1

您可以創建要在wpWelcome之後出現的頁面,並從ShouldSkipPage(wpWelcome)事件函數返回true。

或者,您可以跳過所有頁面,直接跳到「準備安裝」頁面,並重新給出說明文字。

+0

給你第一個建議,或者簡單地設置'DisableWelcomePage'爲'yes'而不跳過。 – TLama

+0

@TLama雖然這將是一個編譯時選項。 – Deanna

+0

啊,我忘了那個條件... – TLama

相關問題