Modular Inno Setupを使用しています
既存の DirectX Detector メソッドを変更しています
http://www.vincenzo.net/isxkb/index.php?title=DirectX_-_How_to_detect_DirectX_version
DirectX 9 をインストールする新しい製品を作成しようとしています
これが私がこれまでに持っているものです。
//========================================
//detectDirectX.iss
//=======================================
[CustomMessages]
directx_title=DirectX End-User Runtimes (June 2010)
en.directx_size=95.6 MB
de.directx_size=95.6 MB
[Code]
const
directx_url = 'http://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe';
procedure DecodeVersion( verstr: String; var verint: array of Integer );
var
i,p: Integer; s: string;
begin
// initialize array
verint := [0,0,0,0];
i := 0;
while ( (Length(verstr) > 0) and (i < 4) ) do
begin
p := pos('.', verstr);
if p > 0 then
begin
if p = 1 then s:= '0' else s:= Copy( verstr, 1, p - 1 );
verint[i] := StrToInt(s);
i := i + 1;
verstr := Copy( verstr, p+1, Length(verstr));
end
else
begin
verint[i] := StrToInt( verstr );
verstr := '';
end;
end;
end;
// This function compares version string
// return -1 if ver1 < ver2
// return 0 if ver1 = ver2
// return 1 if ver1 > ver2
function CompareVersion2( ver1, ver2: String ) : Integer;
var
verint1, verint2: array of Integer;
i: integer;
begin
SetArrayLength( verint1, 4 );
DecodeVersion( ver1, verint1 );
SetArrayLength( verint2, 4 );
DecodeVersion( ver2, verint2 );
Result := 0; i := 0;
while ( (Result = 0) and ( i < 4 ) ) do
begin
if verint1[i] > verint2[i] then
Result := 1
else
if verint1[i] < verint2[i] then
Result := -1
else
Result := 0;
i := i + 1;
end;
end;
// DirectX version is stored in registry as 4.majorversion.minorversion
// DirectX 8.0 is 4.8.0
// DirectX 8.1 is 4.8.1
// DirectX 9.0 is 4.9.0
function GetDirectXVersion(): String;
var
sVersion: String;
begin
sVersion := '';
RegQueryStringValue( HKLM, 'SOFTWARE\Microsoft\DirectX', 'Version', sVersion );
Result := sVersion;
end;
procedure directX();
var ErrorCode: Integer;
begin
// in this case program needs at least directx 9.0
if CompareVersion2( GetDirectXVersion(), '4.9.0') < 0 then
begin
AddProduct('directx_Jun2010_redist.exe',
'/t:' + ExpandConstant('{tmp}\DirectX') + ' /q /c',
CustomMessage('directx_title'),
CustomMessage('directx_size'),
directx_url,
false, false);
//Is there any way to wait until directx_Jun2010_redist.exe has extracted it self before calling the next line?
ShellExec('open', ExpandConstant('{tmp}\DirectX\DXSETUP.exe'), '/silent', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode)
end;
end;
[RUN]の下のメインセットアップファイルwhatever.iss
ファイルを含めました。
#include "scripts\products\custom\detectDirectX.iss"
[コード]の下のメインセットアップファイルwhatever.iss
このメソッドを含めました
directX();
私が抱えている問題は、ダウンロードが正常に行われ、Temp フォルダーに配置されていることです。
AddProduct('directx_Jun2010_redist.exe',
'/t:' + ExpandConstant('{tmp}\DirectX') + ' /q /c',
CustomMessage('directx_title'),
CustomMessage('directx_size'),
directx_url,
false, false);
私は余分なパーを使用しているので
'/t:' + ExpandConstant('{tmp}\DirectX') + ' /q /c'
ダウンロードしたら、DirectXというフォルダーを作成し、すべてをそこに抽出します。少し時間がかかります。
directx_Jun2010_redist.exe の解凍中のようです。
ShellExec('open', ExpandConstant('{tmp}\DirectX\DXSETUP.exe'), '/silent', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode)
が早期に呼び出され、ファイル {tmp}\DirectX\DXSETUP.exe がまだ存在しないため、呼び出されません。
抽出が完了すると、ユーザーはインストール済みの [完了] をクリックし、Temp フォルダーを削除します。
この問題を修正して、directx_Jun2010_redist.exe がファイルを抽出した後、インストーラーが終了する前に DXSETUP.exe を実行できるようにする方法はありますか?