How to install DirectX redistributable from Inno-setup?

前端 未结 1 1146
庸人自扰
庸人自扰 2020-12-12 00:38

I didn\'t find any tip about DirectX installation at Inno-Setup web site. So, is there any sample installation script? I know that I have to add to [Run] sction something li

1条回答
  •  不知归路
    2020-12-12 01:13

    To include it in the setup, you can install it to {tmp} and then [Run] it from there.

    The correct way to install this sort of requirement is to extract in code and call Exec() on it in the PrepareToInstall() event function:

    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;
    

    The ISXKB has an article on how to detect the versions installed.

    0 讨论(0)
提交回复
热议问题