我想用我的Inno安装程序安装程序添加vcredist_x64.exe和vcredist_x86.exe。我的安装程序将如何检测操作系统,无论是64位还是32位,它将根据操作系统安装文件vcredist文件。
答案 0 :(得分:1)
试试这个:
<文件]部分中的添加
Source: "vcredist_x86.exe"; DestDir: {tmp}; Flags: IgnoreVersion replacesameversion; Check: "not IsWin64";
Source: "vcredist_x64.exe"; DestDir: {tmp}; Flags: IgnoreVersion replacesameversion; Check:IsWin64;
并在[代码]部分中执行:
function Launch_VCRedist(svDir:String) : Boolean;
var
svTargetApplication: String;
svParameter: String;
workingDir: String;
showCmd: Integer;
wait: TExecWait;
resultCode: Integer;
VersionMS, VersionLS : Cardinal;
Major, Minor, Rev, Build: Cardinal;
Version:String;
begin
Result := True;
//Optional: if you want to execute silently your redist.exe, add this. This is for vc_redist version from 2005 to 2012
GetVersionNumbers(svDir + '\vcredist_x86.exe', VersionMS, VersionLS);
Major := VersionMS shr 16;
case Major of
11: //2012
begin
svParameter := '/install /passive';
end
10: //2010
begin
svParameter := '/passive /showfinalerror';
end
6: //2005
begin
svParameter := '/q';
end
9: //2008
begin
svParameter := '/Q';
end
end;
workingDir := '';
showCmd := SW_SHOW;
wait := ewWaitUntilTerminated;
retVal := Exec(svDir + '\vcredist_x86.exe', svParameter, workingDir, showCmd, wait, resultCode)
if retVal then
begin
//handle success if necessary; resultCode contains the exit code
end
else begin
//handle failure if necessary; resultCode contains the error code
Result := False;
end;
end;
在CurStepChanged程序中添加:
procedure CurStepChanged(CurStep: TSetupStep);
begin
case CurStep of
ssPostInstall:
b_ret := Launch_VCRedist(ExpandConstant('{tmp}'));
if b_ret Then
begin
//Handle success if necessary
end
else begin
//Handle failure if necessary
end;
end;
end;