2012-01-04 233 views
2

我在Inno-Setup網站上沒有找到關於DirectX安裝的任何提示。那麼,是否有任何示例安裝腳本?我知道,我必須要添加到[運行] sction是這樣的:如何從Inno-setup安裝DirectX redistributable?

Filename: "{src}\DirectX\DXSETUP.exe"; WorkingDir: "{src}\DirectX"; Parameters: "/silent"; Check: DirectX; Flags: waituntilterminated; BeforeInstall: DirectXProgress; 

但如何把它列入到安裝文件,如何提取它,ECT(臨時文件夾?)?

回答

6

要將其包含在設置中,您可以將其安裝到{tmp},然後從那裏安裝[Run]

安裝這種要求正確的方法是在代碼中提取並呼籲它Exec()PrepareToInstall()事件功能:

function PrepareToInstall(var NeedsRestart: Boolean): String; 
var 
    InstallerResult: integer; 
begin 
    //Check if .Net is available already 
    if NeedsDirectX() then begin 
    ExtractTemporaryFile('DXSETUP.exe'); 
    if Exec(ExpandConstant('{tmp}\DXSETUP.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, InstallerResult) then begin 
     case InstallerResult of 
     0: begin 
      //It installed successfully (Or already was), we can continue 
     end; 
     else begin 
      //Some other error 
      result := 'DirectX installation failed. Exit code ' + IntToStr(InstallerResult); 
     end; 
     end; 
    end else begin 
     result := 'DirectX installation failed. ' + SysErrorMessage(InstallerResult); 
    end; 
    end; 
end; 

的ISXKB有article on how to detect the versions installed

+0

此函數'NeedsDirectX()'從哪裏來? – 2012-12-18 14:05:41

相關問題