2017-02-22 110 views
2

如何在一段時間後關閉「完成」頁面上的安裝程序?Inno Setup - 如何在特定時間後關閉完成的安裝程序?

它也可以解釋爲:如何在一段時間的非活動後關閉安裝程序? (關閉/取消安裝)。這可能嗎?

+0

爲什麼要這樣做? –

+0

@MartinPrikryl我想使用類似於MessageBoxTimeout的函數,但是有一個頁面,基本上就是完成頁面,所以一旦安裝完成,完成頁面會在一段時間後關閉。 –

回答

3

當「Finished」頁面顯示後,使用InnoTools InnoCallback庫設置計時器。

[Files] 
Source: "InnoCallback.dll"; Flags: dontcopy 

[Code] 

type 
    TTimerProc = procedure(HandleW, msg, idEvent, TimeSys: LongWord); 

function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): LongWord; 
    external '[email protected] stdcall'; 
function KillTimer(hWnd, nIDEvent: LongWord): LongWord; 
    external '[email protected] stdcall'; 

function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord; 
    external '[email protected]:InnoCallback.dll stdcall delayload'; 

var 
    PageTimeoutTimer: LongWord; 
    PageTimeout: Integer; 

procedure UpdateFinishButton; 
begin 
    WizardForm.NextButton.Caption := 
    Format(SetupMessage(msgButtonFinish) + ' - %ds', [PageTimeout]); 
end; 

procedure PageTimeoutProc(
    H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord); 
begin 
    if PageTimeout > 1 then 
    begin 
    Dec(PageTimeout); 
    UpdateFinishButton; 
    end 
    else 
    begin 
    WizardForm.NextButton.OnClick(WizardForm.NextButton); 
    end; 
end; 

procedure CurPageChanged(CurPageID: Integer); 
begin 
    if CurPageID = wpFinished then 
    begin 
    PageTimeout := 10; 
    UpdateFinishButton; 
    PageTimeoutTimer := SetTimer(0, 0, 1000, WrapTimerProc(@PageTimeoutProc, 4)); 
    end; 
end; 

function NextButtonClick(CurPageID: Integer): Boolean; 
begin 
    if CurPageID = wpFinished then 
    begin 
    KillTimer(0, PageTimeoutTimer); 
    PageTimeoutTimer := 0; 
    end; 
    Result := True; 
end; 

Timeout of Finished page


相關的問題:

相關問題