Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
972 views
in Technique[技术] by (71.8m points)

installation - How to install DirectX redistributable from Inno-setup?

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 like this:

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

But how to include it into setup file (temp folder?), how to extract it, ect?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...