我想用我的 Inno Setup 安装程序添加 vcredist_x64.exe 和 vcredist_x86.exe。我的安装程序将如何检测操作系统是 64 位还是 32 位,并将根据操作系统安装文件 vcredist 文件。
1 回答
1
尝试这个:
在 [文件] 部分添加
Source: "vcredist_x86.exe"; DestDir: {tmp}; Flags: IgnoreVersion replacesameversion; Check: "not IsWin64";
Source: "vcredist_x64.exe"; DestDir: {tmp}; Flags: IgnoreVersion replacesameversion; Check:IsWin64;
并在您的 [Code] 部分执行:
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;
于 2015-10-08T10:45:59.883 回答