如何从Inno-setup安装DirectX可再发行组件?

时间:2012-01-04 08:14:46

标签: installation directx inno-setup

我没有在Inno-Setup网站上找到有关DirectX安装的任何提示。那么,是否有任何示例安装脚本?我知道我必须添加[Run] sction这样的东西:

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

但如何将其包含在设置文件(临时文件夹?)中,如何提取它,等等?

1 个答案:

答案 0 :(得分: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